@vibecheckai/cli 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +532 -0
- package/dist/autopatch/verified-autopatch.d.ts +111 -0
- package/dist/autopatch/verified-autopatch.d.ts.map +1 -0
- package/dist/autopatch/verified-autopatch.js +503 -0
- package/dist/autopatch/verified-autopatch.js.map +1 -0
- package/dist/bundles/guardrail-core.js +25799 -0
- package/dist/bundles/guardrail-security.js +208687 -0
- package/dist/bundles/guardrail-ship.js +2318 -0
- package/dist/bundles/index.js +8 -0
- package/dist/commands/autopilot-decision.d.ts +24 -0
- package/dist/commands/autopilot-decision.d.ts.map +1 -0
- package/dist/commands/autopilot-decision.js +304 -0
- package/dist/commands/autopilot-decision.js.map +1 -0
- package/dist/commands/autopilot.d.ts +33 -0
- package/dist/commands/autopilot.d.ts.map +1 -0
- package/dist/commands/autopilot.js +1539 -0
- package/dist/commands/autopilot.js.map +1 -0
- package/dist/commands/baseline.d.ts +7 -0
- package/dist/commands/baseline.d.ts.map +1 -0
- package/dist/commands/baseline.js +79 -0
- package/dist/commands/baseline.js.map +1 -0
- package/dist/commands/cache.d.ts +13 -0
- package/dist/commands/cache.d.ts.map +1 -0
- package/dist/commands/cache.js +165 -0
- package/dist/commands/cache.js.map +1 -0
- package/dist/commands/checkpoint.d.ts +8 -0
- package/dist/commands/checkpoint.d.ts.map +1 -0
- package/dist/commands/checkpoint.js +35 -0
- package/dist/commands/checkpoint.js.map +1 -0
- package/dist/commands/context.d.ts +8 -0
- package/dist/commands/context.d.ts.map +1 -0
- package/dist/commands/context.js +340 -0
- package/dist/commands/context.js.map +1 -0
- package/dist/commands/debug.d.ts +78 -0
- package/dist/commands/debug.d.ts.map +1 -0
- package/dist/commands/debug.js +381 -0
- package/dist/commands/debug.js.map +1 -0
- package/dist/commands/doctor.d.ts +17 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +226 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/evidence.d.ts +45 -0
- package/dist/commands/evidence.d.ts.map +1 -0
- package/dist/commands/evidence.js +197 -0
- package/dist/commands/evidence.js.map +1 -0
- package/dist/commands/explain.d.ts +8 -0
- package/dist/commands/explain.d.ts.map +1 -0
- package/dist/commands/explain.js +52 -0
- package/dist/commands/explain.js.map +1 -0
- package/dist/commands/fix-consolidated.d.ts +19 -0
- package/dist/commands/fix-consolidated.d.ts.map +1 -0
- package/dist/commands/fix-consolidated.js +165 -0
- package/dist/commands/fix-consolidated.js.map +1 -0
- package/dist/commands/index.d.ts +8 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +15 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/init.d.ts +8 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +125 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/launcher.d.ts +10 -0
- package/dist/commands/launcher.d.ts.map +1 -0
- package/dist/commands/launcher.js +174 -0
- package/dist/commands/launcher.js.map +1 -0
- package/dist/commands/on.d.ts +8 -0
- package/dist/commands/on.d.ts.map +1 -0
- package/dist/commands/on.js +123 -0
- package/dist/commands/on.js.map +1 -0
- package/dist/commands/preview.d.ts +54 -0
- package/dist/commands/preview.d.ts.map +1 -0
- package/dist/commands/preview.js +352 -0
- package/dist/commands/preview.js.map +1 -0
- package/dist/commands/quality/check.d.ts +31 -0
- package/dist/commands/quality/check.d.ts.map +1 -0
- package/dist/commands/quality/check.js +242 -0
- package/dist/commands/quality/check.js.map +1 -0
- package/dist/commands/quality/index.d.ts +8 -0
- package/dist/commands/quality/index.d.ts.map +1 -0
- package/dist/commands/quality/index.js +14 -0
- package/dist/commands/quality/index.js.map +1 -0
- package/dist/commands/quality/setup-quality.d.ts +23 -0
- package/dist/commands/quality/setup-quality.d.ts.map +1 -0
- package/dist/commands/quality/setup-quality.js +452 -0
- package/dist/commands/quality/setup-quality.js.map +1 -0
- package/dist/commands/quality/tidy.d.ts +41 -0
- package/dist/commands/quality/tidy.d.ts.map +1 -0
- package/dist/commands/quality/tidy.js +466 -0
- package/dist/commands/quality/tidy.js.map +1 -0
- package/dist/commands/quality/utils.d.ts +73 -0
- package/dist/commands/quality/utils.d.ts.map +1 -0
- package/dist/commands/quality/utils.js +158 -0
- package/dist/commands/quality/utils.js.map +1 -0
- package/dist/commands/replay.d.ts +8 -0
- package/dist/commands/replay.d.ts.map +1 -0
- package/dist/commands/replay.js +52 -0
- package/dist/commands/replay.js.map +1 -0
- package/dist/commands/scan-consolidated.d.ts +61 -0
- package/dist/commands/scan-consolidated.d.ts.map +1 -0
- package/dist/commands/scan-consolidated.js +243 -0
- package/dist/commands/scan-consolidated.js.map +1 -0
- package/dist/commands/scan-secrets.d.ts +47 -0
- package/dist/commands/scan-secrets.d.ts.map +1 -0
- package/dist/commands/scan-secrets.js +225 -0
- package/dist/commands/scan-secrets.js.map +1 -0
- package/dist/commands/scan-vulnerabilities-enhanced.d.ts +41 -0
- package/dist/commands/scan-vulnerabilities-enhanced.d.ts.map +1 -0
- package/dist/commands/scan-vulnerabilities-enhanced.js +368 -0
- package/dist/commands/scan-vulnerabilities-enhanced.js.map +1 -0
- package/dist/commands/scan-vulnerabilities-osv.d.ts +58 -0
- package/dist/commands/scan-vulnerabilities-osv.d.ts.map +1 -0
- package/dist/commands/scan-vulnerabilities-osv.js +716 -0
- package/dist/commands/scan-vulnerabilities-osv.js.map +1 -0
- package/dist/commands/scan-vulnerabilities.d.ts +32 -0
- package/dist/commands/scan-vulnerabilities.d.ts.map +1 -0
- package/dist/commands/scan-vulnerabilities.js +283 -0
- package/dist/commands/scan-vulnerabilities.js.map +1 -0
- package/dist/commands/secrets-allowlist.d.ts +7 -0
- package/dist/commands/secrets-allowlist.d.ts.map +1 -0
- package/dist/commands/secrets-allowlist.js +85 -0
- package/dist/commands/secrets-allowlist.js.map +1 -0
- package/dist/commands/ship-consolidated.d.ts +58 -0
- package/dist/commands/ship-consolidated.d.ts.map +1 -0
- package/dist/commands/ship-consolidated.js +515 -0
- package/dist/commands/ship-consolidated.js.map +1 -0
- package/dist/commands/stats.d.ts +8 -0
- package/dist/commands/stats.d.ts.map +1 -0
- package/dist/commands/stats.js +134 -0
- package/dist/commands/stats.js.map +1 -0
- package/dist/commands/upgrade.d.ts +8 -0
- package/dist/commands/upgrade.d.ts.map +1 -0
- package/dist/commands/upgrade.js +30 -0
- package/dist/commands/upgrade.js.map +1 -0
- package/dist/fix/analytics.d.ts +121 -0
- package/dist/fix/analytics.d.ts.map +1 -0
- package/dist/fix/analytics.js +289 -0
- package/dist/fix/analytics.js.map +1 -0
- package/dist/fix/applicator.d.ts +44 -0
- package/dist/fix/applicator.d.ts.map +1 -0
- package/dist/fix/applicator.js +144 -0
- package/dist/fix/applicator.js.map +1 -0
- package/dist/fix/audit.d.ts +61 -0
- package/dist/fix/audit.d.ts.map +1 -0
- package/dist/fix/audit.js +149 -0
- package/dist/fix/audit.js.map +1 -0
- package/dist/fix/backup.d.ts +38 -0
- package/dist/fix/backup.d.ts.map +1 -0
- package/dist/fix/backup.js +154 -0
- package/dist/fix/backup.js.map +1 -0
- package/dist/fix/config.d.ts +78 -0
- package/dist/fix/config.d.ts.map +1 -0
- package/dist/fix/config.js +200 -0
- package/dist/fix/config.js.map +1 -0
- package/dist/fix/engine.d.ts +55 -0
- package/dist/fix/engine.d.ts.map +1 -0
- package/dist/fix/engine.js +285 -0
- package/dist/fix/engine.js.map +1 -0
- package/dist/fix/impact.d.ts +74 -0
- package/dist/fix/impact.d.ts.map +1 -0
- package/dist/fix/impact.js +281 -0
- package/dist/fix/impact.js.map +1 -0
- package/dist/fix/index.d.ts +5 -0
- package/dist/fix/index.d.ts.map +1 -0
- package/dist/fix/index.js +12 -0
- package/dist/fix/index.js.map +1 -0
- package/dist/fix/interactive.d.ts +22 -0
- package/dist/fix/interactive.d.ts.map +1 -0
- package/dist/fix/interactive.js +172 -0
- package/dist/fix/interactive.js.map +1 -0
- package/dist/fix/learning.d.ts +109 -0
- package/dist/fix/learning.d.ts.map +1 -0
- package/dist/fix/learning.js +296 -0
- package/dist/fix/learning.js.map +1 -0
- package/dist/fix/metrics.d.ts +106 -0
- package/dist/fix/metrics.d.ts.map +1 -0
- package/dist/fix/metrics.js +138 -0
- package/dist/fix/metrics.js.map +1 -0
- package/dist/fix/parallel.d.ts +69 -0
- package/dist/fix/parallel.d.ts.map +1 -0
- package/dist/fix/parallel.js +203 -0
- package/dist/fix/parallel.js.map +1 -0
- package/dist/fix/report.d.ts +40 -0
- package/dist/fix/report.d.ts.map +1 -0
- package/dist/fix/report.js +212 -0
- package/dist/fix/report.js.map +1 -0
- package/dist/fix/strategy.d.ts +53 -0
- package/dist/fix/strategy.d.ts.map +1 -0
- package/dist/fix/strategy.js +143 -0
- package/dist/fix/strategy.js.map +1 -0
- package/dist/fix/templates.d.ts +58 -0
- package/dist/fix/templates.d.ts.map +1 -0
- package/dist/fix/templates.js +259 -0
- package/dist/fix/templates.js.map +1 -0
- package/dist/fix/testing.d.ts +68 -0
- package/dist/fix/testing.d.ts.map +1 -0
- package/dist/fix/testing.js +245 -0
- package/dist/fix/testing.js.map +1 -0
- package/dist/fix/validation.d.ts +71 -0
- package/dist/fix/validation.d.ts.map +1 -0
- package/dist/fix/validation.js +267 -0
- package/dist/fix/validation.js.map +1 -0
- package/dist/fix/visualization.d.ts +73 -0
- package/dist/fix/visualization.d.ts.map +1 -0
- package/dist/fix/visualization.js +243 -0
- package/dist/fix/visualization.js.map +1 -0
- package/dist/formatters/index.d.ts +6 -0
- package/dist/formatters/index.d.ts.map +1 -0
- package/dist/formatters/index.js +11 -0
- package/dist/formatters/index.js.map +1 -0
- package/dist/formatters/sarif-enhanced.d.ts +78 -0
- package/dist/formatters/sarif-enhanced.d.ts.map +1 -0
- package/dist/formatters/sarif-enhanced.js +144 -0
- package/dist/formatters/sarif-enhanced.js.map +1 -0
- package/dist/formatters/sarif-v2.d.ts +121 -0
- package/dist/formatters/sarif-v2.d.ts.map +1 -0
- package/dist/formatters/sarif-v2.js +356 -0
- package/dist/formatters/sarif-v2.js.map +1 -0
- package/dist/formatters/sarif.d.ts +72 -0
- package/dist/formatters/sarif.d.ts.map +1 -0
- package/dist/formatters/sarif.js +146 -0
- package/dist/formatters/sarif.js.map +1 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4455 -0
- package/dist/index.js.map +1 -0
- package/dist/init/ci-generator.d.ts +18 -0
- package/dist/init/ci-generator.d.ts.map +1 -0
- package/dist/init/ci-generator.js +317 -0
- package/dist/init/ci-generator.js.map +1 -0
- package/dist/init/detect-framework.d.ts +15 -0
- package/dist/init/detect-framework.d.ts.map +1 -0
- package/dist/init/detect-framework.js +301 -0
- package/dist/init/detect-framework.js.map +1 -0
- package/dist/init/hooks-installer.d.ts +22 -0
- package/dist/init/hooks-installer.d.ts.map +1 -0
- package/dist/init/hooks-installer.js +310 -0
- package/dist/init/hooks-installer.js.map +1 -0
- package/dist/init/index.d.ts +8 -0
- package/dist/init/index.d.ts.map +1 -0
- package/dist/init/index.js +22 -0
- package/dist/init/index.js.map +1 -0
- package/dist/init/templates.d.ts +401 -0
- package/dist/init/templates.d.ts.map +1 -0
- package/dist/init/templates.js +240 -0
- package/dist/init/templates.js.map +1 -0
- package/dist/mcp/server.d.ts +12 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +42 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/telemetry.d.ts +40 -0
- package/dist/mcp/telemetry.d.ts.map +1 -0
- package/dist/mcp/telemetry.js +98 -0
- package/dist/mcp/telemetry.js.map +1 -0
- package/dist/reality/no-dead-buttons/button-sweep-generator.d.ts +32 -0
- package/dist/reality/no-dead-buttons/button-sweep-generator.d.ts.map +1 -0
- package/dist/reality/no-dead-buttons/button-sweep-generator.js +236 -0
- package/dist/reality/no-dead-buttons/button-sweep-generator.js.map +1 -0
- package/dist/reality/no-dead-buttons/index.d.ts +11 -0
- package/dist/reality/no-dead-buttons/index.d.ts.map +1 -0
- package/dist/reality/no-dead-buttons/index.js +18 -0
- package/dist/reality/no-dead-buttons/index.js.map +1 -0
- package/dist/reality/no-dead-buttons/static-scanner.d.ts +34 -0
- package/dist/reality/no-dead-buttons/static-scanner.d.ts.map +1 -0
- package/dist/reality/no-dead-buttons/static-scanner.js +230 -0
- package/dist/reality/no-dead-buttons/static-scanner.js.map +1 -0
- package/dist/reality/reality-graph.d.ts +192 -0
- package/dist/reality/reality-graph.d.ts.map +1 -0
- package/dist/reality/reality-graph.js +600 -0
- package/dist/reality/reality-graph.js.map +1 -0
- package/dist/reality/reality-runner.d.ts +89 -0
- package/dist/reality/reality-runner.d.ts.map +1 -0
- package/dist/reality/reality-runner.js +540 -0
- package/dist/reality/reality-runner.js.map +1 -0
- package/dist/reality/receipt-generator.d.ts +152 -0
- package/dist/reality/receipt-generator.d.ts.map +1 -0
- package/dist/reality/receipt-generator.js +495 -0
- package/dist/reality/receipt-generator.js.map +1 -0
- package/dist/reality/runtime-tracer.d.ts +75 -0
- package/dist/reality/runtime-tracer.d.ts.map +1 -0
- package/dist/reality/runtime-tracer.js +109 -0
- package/dist/reality/runtime-tracer.js.map +1 -0
- package/dist/runtime/auth-utils.d.ts +43 -0
- package/dist/runtime/auth-utils.d.ts.map +1 -0
- package/dist/runtime/auth-utils.js +130 -0
- package/dist/runtime/auth-utils.js.map +1 -0
- package/dist/runtime/cli-errors.d.ts +38 -0
- package/dist/runtime/cli-errors.d.ts.map +1 -0
- package/dist/runtime/cli-errors.js +354 -0
- package/dist/runtime/cli-errors.js.map +1 -0
- package/dist/runtime/client.d.ts +74 -0
- package/dist/runtime/client.d.ts.map +1 -0
- package/dist/runtime/client.js +222 -0
- package/dist/runtime/client.js.map +1 -0
- package/dist/runtime/creds.d.ts +48 -0
- package/dist/runtime/creds.d.ts.map +1 -0
- package/dist/runtime/creds.js +245 -0
- package/dist/runtime/creds.js.map +1 -0
- package/dist/runtime/exit-codes.d.ts +49 -0
- package/dist/runtime/exit-codes.d.ts.map +1 -0
- package/dist/runtime/exit-codes.js +93 -0
- package/dist/runtime/exit-codes.js.map +1 -0
- package/dist/runtime/index.d.ts +9 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +25 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/json-output.d.ts +42 -0
- package/dist/runtime/json-output.d.ts.map +1 -0
- package/dist/runtime/json-output.js +59 -0
- package/dist/runtime/json-output.js.map +1 -0
- package/dist/runtime/owner-mode.d.ts +48 -0
- package/dist/runtime/owner-mode.d.ts.map +1 -0
- package/dist/runtime/owner-mode.js +284 -0
- package/dist/runtime/owner-mode.js.map +1 -0
- package/dist/runtime/semver.d.ts +37 -0
- package/dist/runtime/semver.d.ts.map +1 -0
- package/dist/runtime/semver.js +110 -0
- package/dist/runtime/semver.js.map +1 -0
- package/dist/scan/dead-ui-detector.d.ts +48 -0
- package/dist/scan/dead-ui-detector.d.ts.map +1 -0
- package/dist/scan/dead-ui-detector.js +170 -0
- package/dist/scan/dead-ui-detector.js.map +1 -0
- package/dist/scan/playwright-sweep.d.ts +40 -0
- package/dist/scan/playwright-sweep.d.ts.map +1 -0
- package/dist/scan/playwright-sweep.js +216 -0
- package/dist/scan/playwright-sweep.js.map +1 -0
- package/dist/scan/proof-bundle.d.ts +25 -0
- package/dist/scan/proof-bundle.d.ts.map +1 -0
- package/dist/scan/proof-bundle.js +203 -0
- package/dist/scan/proof-bundle.js.map +1 -0
- package/dist/scan/proof-graph.d.ts +59 -0
- package/dist/scan/proof-graph.d.ts.map +1 -0
- package/dist/scan/proof-graph.js +64 -0
- package/dist/scan/proof-graph.js.map +1 -0
- package/dist/scan/reality-sniff.d.ts +56 -0
- package/dist/scan/reality-sniff.d.ts.map +1 -0
- package/dist/scan/reality-sniff.js +200 -0
- package/dist/scan/reality-sniff.js.map +1 -0
- package/dist/scan/structural-verifier.d.ts +20 -0
- package/dist/scan/structural-verifier.d.ts.map +1 -0
- package/dist/scan/structural-verifier.js +112 -0
- package/dist/scan/structural-verifier.js.map +1 -0
- package/dist/scan/verification-engine.d.ts +47 -0
- package/dist/scan/verification-engine.d.ts.map +1 -0
- package/dist/scan/verification-engine.js +141 -0
- package/dist/scan/verification-engine.js.map +1 -0
- package/dist/scanner/baseline.d.ts +52 -0
- package/dist/scanner/baseline.d.ts.map +1 -0
- package/dist/scanner/baseline.js +85 -0
- package/dist/scanner/baseline.js.map +1 -0
- package/dist/scanner/incremental.d.ts +30 -0
- package/dist/scanner/incremental.d.ts.map +1 -0
- package/dist/scanner/incremental.js +82 -0
- package/dist/scanner/incremental.js.map +1 -0
- package/dist/scanner/index.d.ts +8 -0
- package/dist/scanner/index.d.ts.map +1 -0
- package/dist/scanner/index.js +15 -0
- package/dist/scanner/index.js.map +1 -0
- package/dist/scanner/parallel.d.ts +43 -0
- package/dist/scanner/parallel.d.ts.map +1 -0
- package/dist/scanner/parallel.js +99 -0
- package/dist/scanner/parallel.js.map +1 -0
- package/dist/scanner/placeholder-detector.d.ts +56 -0
- package/dist/scanner/placeholder-detector.d.ts.map +1 -0
- package/dist/scanner/placeholder-detector.js +220 -0
- package/dist/scanner/placeholder-detector.js.map +1 -0
- package/dist/scanner/route-detector.d.ts +100 -0
- package/dist/scanner/route-detector.d.ts.map +1 -0
- package/dist/scanner/route-detector.js +455 -0
- package/dist/scanner/route-detector.js.map +1 -0
- package/dist/scanner/scoring.d.ts +67 -0
- package/dist/scanner/scoring.d.ts.map +1 -0
- package/dist/scanner/scoring.js +284 -0
- package/dist/scanner/scoring.js.map +1 -0
- package/dist/ship-baseline.d.ts +56 -0
- package/dist/ship-baseline.d.ts.map +1 -0
- package/dist/ship-baseline.js +194 -0
- package/dist/ship-baseline.js.map +1 -0
- package/dist/ship-config.d.ts +91 -0
- package/dist/ship-config.d.ts.map +1 -0
- package/dist/ship-config.js +133 -0
- package/dist/ship-config.js.map +1 -0
- package/dist/ship-data-loader.d.ts +70 -0
- package/dist/ship-data-loader.d.ts.map +1 -0
- package/dist/ship-data-loader.js +301 -0
- package/dist/ship-data-loader.js.map +1 -0
- package/dist/standalone.d.ts +1 -0
- package/dist/standalone.d.ts.map +1 -0
- package/dist/standalone.js +1 -0
- package/dist/standalone.js.map +1 -0
- package/dist/truth-pack/index.d.ts +102 -0
- package/dist/truth-pack/index.d.ts.map +1 -0
- package/dist/truth-pack/index.js +694 -0
- package/dist/truth-pack/index.js.map +1 -0
- package/dist/ui/frame.d.ts +68 -0
- package/dist/ui/frame.d.ts.map +1 -0
- package/dist/ui/frame.js +165 -0
- package/dist/ui/frame.js.map +1 -0
- package/dist/ui/index.d.ts +5 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +16 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui.d.ts +36 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +45 -0
- package/dist/ui.js.map +1 -0
- package/dist/utils/ai-helpers.d.ts +72 -0
- package/dist/utils/ai-helpers.d.ts.map +1 -0
- package/dist/utils/ai-helpers.js +339 -0
- package/dist/utils/ai-helpers.js.map +1 -0
- package/dist/utils/validation.d.ts +34 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +160 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Fix Testing Framework
|
|
4
|
+
*
|
|
5
|
+
* Tests fixes before application using sandbox environments,
|
|
6
|
+
* unit tests, and validation checks.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.FixTester = void 0;
|
|
10
|
+
const fs_1 = require("fs");
|
|
11
|
+
const path_1 = require("path");
|
|
12
|
+
const child_process_1 = require("child_process");
|
|
13
|
+
class FixTester {
|
|
14
|
+
constructor(projectPath, config = {}) {
|
|
15
|
+
this.projectPath = projectPath;
|
|
16
|
+
this.sandboxPath = (0, path_1.join)(projectPath, '.guardrail', 'sandbox');
|
|
17
|
+
this.config = {
|
|
18
|
+
runTests: true,
|
|
19
|
+
testTimeout: 60000,
|
|
20
|
+
requireAllTestsPass: false,
|
|
21
|
+
sandboxEnabled: false,
|
|
22
|
+
...config,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Test a fix before application
|
|
27
|
+
*/
|
|
28
|
+
async testFix(fix) {
|
|
29
|
+
const startTime = Date.now();
|
|
30
|
+
if (!this.config.runTests) {
|
|
31
|
+
return {
|
|
32
|
+
fix,
|
|
33
|
+
testResult: {
|
|
34
|
+
passed: true,
|
|
35
|
+
testsRun: 0,
|
|
36
|
+
testsPassed: 0,
|
|
37
|
+
testsFailed: 0,
|
|
38
|
+
errors: [],
|
|
39
|
+
warnings: ['Tests skipped'],
|
|
40
|
+
duration: Date.now() - startTime,
|
|
41
|
+
},
|
|
42
|
+
safeToApply: true,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
// Run tests on current codebase
|
|
47
|
+
const testResult = await this.runTests();
|
|
48
|
+
// Basic validation
|
|
49
|
+
const validationErrors = this.validateFix(fix);
|
|
50
|
+
if (validationErrors.length > 0) {
|
|
51
|
+
return {
|
|
52
|
+
fix,
|
|
53
|
+
testResult: {
|
|
54
|
+
passed: false,
|
|
55
|
+
testsRun: testResult.testsRun,
|
|
56
|
+
testsPassed: testResult.testsPassed,
|
|
57
|
+
testsFailed: testResult.testsFailed,
|
|
58
|
+
errors: [...testResult.errors, ...validationErrors],
|
|
59
|
+
warnings: testResult.warnings,
|
|
60
|
+
duration: Date.now() - startTime,
|
|
61
|
+
},
|
|
62
|
+
safeToApply: false,
|
|
63
|
+
reason: 'Validation failed',
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const safeToApply = testResult.passed || !this.config.requireAllTestsPass;
|
|
67
|
+
return {
|
|
68
|
+
fix,
|
|
69
|
+
testResult,
|
|
70
|
+
safeToApply,
|
|
71
|
+
reason: safeToApply ? undefined : 'Tests failed',
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
return {
|
|
76
|
+
fix,
|
|
77
|
+
testResult: {
|
|
78
|
+
passed: false,
|
|
79
|
+
testsRun: 0,
|
|
80
|
+
testsPassed: 0,
|
|
81
|
+
testsFailed: 0,
|
|
82
|
+
errors: [error.message || 'Test execution failed'],
|
|
83
|
+
warnings: [],
|
|
84
|
+
duration: Date.now() - startTime,
|
|
85
|
+
},
|
|
86
|
+
safeToApply: false,
|
|
87
|
+
reason: 'Test execution failed',
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Test a pack of fixes
|
|
93
|
+
*/
|
|
94
|
+
async testPack(pack) {
|
|
95
|
+
const results = [];
|
|
96
|
+
// Test fixes individually
|
|
97
|
+
for (const fix of pack.fixes) {
|
|
98
|
+
const result = await this.testFix(fix);
|
|
99
|
+
results.push(result);
|
|
100
|
+
}
|
|
101
|
+
return results;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Run tests in the project
|
|
105
|
+
*/
|
|
106
|
+
async runTests() {
|
|
107
|
+
const startTime = Date.now();
|
|
108
|
+
try {
|
|
109
|
+
// Detect test command
|
|
110
|
+
const testCommand = this.config.testCommand || this.detectTestCommand();
|
|
111
|
+
if (!testCommand) {
|
|
112
|
+
return {
|
|
113
|
+
passed: true,
|
|
114
|
+
testsRun: 0,
|
|
115
|
+
testsPassed: 0,
|
|
116
|
+
testsFailed: 0,
|
|
117
|
+
errors: [],
|
|
118
|
+
warnings: ['No test command found'],
|
|
119
|
+
duration: Date.now() - startTime,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
// Run tests
|
|
123
|
+
const output = (0, child_process_1.execSync)(testCommand, {
|
|
124
|
+
cwd: this.projectPath,
|
|
125
|
+
encoding: 'utf-8',
|
|
126
|
+
stdio: 'pipe',
|
|
127
|
+
timeout: this.config.testTimeout,
|
|
128
|
+
});
|
|
129
|
+
// Parse test results (simplified - would need test framework-specific parsing)
|
|
130
|
+
const testsRun = this.extractTestCount(output, 'tests?\\s+(?:run|executed|passed)');
|
|
131
|
+
const testsPassed = this.extractTestCount(output, 'passed');
|
|
132
|
+
const testsFailed = testsRun - testsPassed;
|
|
133
|
+
return {
|
|
134
|
+
passed: testsFailed === 0,
|
|
135
|
+
testsRun,
|
|
136
|
+
testsPassed,
|
|
137
|
+
testsFailed,
|
|
138
|
+
errors: testsFailed > 0 ? ['Some tests failed'] : [],
|
|
139
|
+
warnings: [],
|
|
140
|
+
duration: Date.now() - startTime,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
// Test execution failed
|
|
145
|
+
const output = error.stdout || error.stderr || error.message || '';
|
|
146
|
+
return {
|
|
147
|
+
passed: false,
|
|
148
|
+
testsRun: 0,
|
|
149
|
+
testsPassed: 0,
|
|
150
|
+
testsFailed: 0,
|
|
151
|
+
errors: [output.substring(0, 500)], // Limit error message length
|
|
152
|
+
warnings: [],
|
|
153
|
+
duration: Date.now() - startTime,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Detect test command from package.json
|
|
159
|
+
*/
|
|
160
|
+
detectTestCommand() {
|
|
161
|
+
const packageJsonPath = (0, path_1.join)(this.projectPath, 'package.json');
|
|
162
|
+
if (!(0, fs_1.existsSync)(packageJsonPath)) {
|
|
163
|
+
return undefined;
|
|
164
|
+
}
|
|
165
|
+
try {
|
|
166
|
+
const packageJson = JSON.parse((0, fs_1.readFileSync)(packageJsonPath, 'utf-8'));
|
|
167
|
+
const scripts = packageJson.scripts || {};
|
|
168
|
+
// Try common test commands
|
|
169
|
+
if (scripts.test)
|
|
170
|
+
return 'npm test';
|
|
171
|
+
if (scripts['test:unit'])
|
|
172
|
+
return 'npm run test:unit';
|
|
173
|
+
if (scripts['test:ci'])
|
|
174
|
+
return 'npm run test:ci';
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
catch {
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Extract test count from output
|
|
183
|
+
*/
|
|
184
|
+
extractTestCount(output, pattern) {
|
|
185
|
+
const regex = new RegExp(`(\\d+)\\s+${pattern}`, 'i');
|
|
186
|
+
const match = output.match(regex);
|
|
187
|
+
return match ? parseInt(match[1], 10) : 0;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Validate fix before testing
|
|
191
|
+
*/
|
|
192
|
+
validateFix(fix) {
|
|
193
|
+
const errors = [];
|
|
194
|
+
// Check file exists
|
|
195
|
+
const filePath = (0, path_1.join)(this.projectPath, fix.file);
|
|
196
|
+
if (!(0, fs_1.existsSync)(filePath)) {
|
|
197
|
+
errors.push(`File does not exist: ${fix.file}`);
|
|
198
|
+
return errors;
|
|
199
|
+
}
|
|
200
|
+
// Check line number is valid
|
|
201
|
+
const content = (0, fs_1.readFileSync)(filePath, 'utf-8');
|
|
202
|
+
const lines = content.split('\n');
|
|
203
|
+
if (fix.line <= 0 || fix.line > lines.length) {
|
|
204
|
+
errors.push(`Invalid line number: ${fix.line} (file has ${lines.length} lines)`);
|
|
205
|
+
}
|
|
206
|
+
// Check code matches
|
|
207
|
+
if (fix.line > 0 && fix.line <= lines.length) {
|
|
208
|
+
const actualLine = lines[fix.line - 1];
|
|
209
|
+
if (actualLine.trim() !== fix.oldCode.trim()) {
|
|
210
|
+
errors.push(`Code mismatch at line ${fix.line}`);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return errors;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Create sandbox environment (future enhancement)
|
|
217
|
+
*/
|
|
218
|
+
async createSandbox() {
|
|
219
|
+
if (!this.config.sandboxEnabled) {
|
|
220
|
+
return this.projectPath;
|
|
221
|
+
}
|
|
222
|
+
// Create sandbox directory
|
|
223
|
+
if (!(0, fs_1.existsSync)(this.sandboxPath)) {
|
|
224
|
+
(0, fs_1.mkdirSync)(this.sandboxPath, { recursive: true });
|
|
225
|
+
}
|
|
226
|
+
// Copy project files (simplified - would need full copy)
|
|
227
|
+
// This is a placeholder for future sandbox implementation
|
|
228
|
+
return this.sandboxPath;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Cleanup sandbox (future enhancement)
|
|
232
|
+
*/
|
|
233
|
+
cleanupSandbox() {
|
|
234
|
+
if (this.config.sandboxEnabled && (0, fs_1.existsSync)(this.sandboxPath)) {
|
|
235
|
+
try {
|
|
236
|
+
(0, fs_1.rmSync)(this.sandboxPath, { recursive: true, force: true });
|
|
237
|
+
}
|
|
238
|
+
catch {
|
|
239
|
+
// Ignore cleanup errors
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
exports.FixTester = FixTester;
|
|
245
|
+
//# sourceMappingURL=testing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.js","sourceRoot":"","sources":["../../src/fix/testing.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,2BAA8F;AAC9F,+BAA4B;AAC5B,iDAAyC;AA2BzC,MAAa,SAAS;IAKpB,YACE,WAAmB,EACnB,SAAqC,EAAE;QAEvC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,WAAW,GAAG,IAAA,WAAI,EAAC,WAAW,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;QAC9D,IAAI,CAAC,MAAM,GAAG;YACZ,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,KAAK;YAClB,mBAAmB,EAAE,KAAK;YAC1B,cAAc,EAAE,KAAK;YACrB,GAAG,MAAM;SACV,CAAC;IACJ,CAAC;IAED;;OAEG;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AAC;QAED,2BAA2B;QAC3B,IAAI,CAAC,IAAA,eAAU,EAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;YAClC,IAAA,cAAS,EAAC,IAAI,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACnD,CAAC;QAED,yDAAyD;QACzD,0DAA0D;QAE1D,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED;;OAEG;IACK,cAAc;QACpB,IAAI,IAAI,CAAC,MAAM,CAAC,cAAc,IAAI,IAAA,eAAU,EAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;YAC/D,IAAI,CAAC;gBACH,IAAA,WAAM,EAAC,IAAI,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YAC7D,CAAC;YAAC,MAAM,CAAC;gBACP,wBAAwB;YAC1B,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAtQD,8BAsQC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fix Validation Framework
|
|
3
|
+
*
|
|
4
|
+
* Provides comprehensive validation before and after fix application,
|
|
5
|
+
* including pre-checks, post-checks, and continuous validation.
|
|
6
|
+
*/
|
|
7
|
+
import { FixPack, Fix } from './engine';
|
|
8
|
+
export interface ValidationRule {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
validate: (context: ValidationContext) => ValidationResult;
|
|
13
|
+
severity: 'error' | 'warning' | 'info';
|
|
14
|
+
}
|
|
15
|
+
export interface ValidationContext {
|
|
16
|
+
fix: Fix;
|
|
17
|
+
filePath: string;
|
|
18
|
+
fileContent: string;
|
|
19
|
+
projectPath: string;
|
|
20
|
+
packs: FixPack[];
|
|
21
|
+
}
|
|
22
|
+
export interface ValidationResult {
|
|
23
|
+
passed: boolean;
|
|
24
|
+
message?: string;
|
|
25
|
+
severity?: 'error' | 'warning' | 'info';
|
|
26
|
+
details?: Record<string, any>;
|
|
27
|
+
}
|
|
28
|
+
export interface ValidationReport {
|
|
29
|
+
overall: boolean;
|
|
30
|
+
rules: Array<{
|
|
31
|
+
rule: ValidationRule;
|
|
32
|
+
result: ValidationResult;
|
|
33
|
+
}>;
|
|
34
|
+
errors: ValidationResult[];
|
|
35
|
+
warnings: ValidationResult[];
|
|
36
|
+
passed: number;
|
|
37
|
+
failed: number;
|
|
38
|
+
}
|
|
39
|
+
export declare class FixValidator {
|
|
40
|
+
private rules;
|
|
41
|
+
constructor();
|
|
42
|
+
/**
|
|
43
|
+
* Register a validation rule
|
|
44
|
+
*/
|
|
45
|
+
registerRule(rule: ValidationRule): void;
|
|
46
|
+
/**
|
|
47
|
+
* Validate a fix before application
|
|
48
|
+
*/
|
|
49
|
+
validatePre(fix: Fix, context: Omit<ValidationContext, 'fix'>): Promise<ValidationReport>;
|
|
50
|
+
/**
|
|
51
|
+
* Validate a fix after application
|
|
52
|
+
*/
|
|
53
|
+
validatePost(fix: Fix, context: Omit<ValidationContext, 'fix'>): Promise<ValidationReport>;
|
|
54
|
+
/**
|
|
55
|
+
* Validate using all rules
|
|
56
|
+
*/
|
|
57
|
+
private validate;
|
|
58
|
+
/**
|
|
59
|
+
* Register default validation rules
|
|
60
|
+
*/
|
|
61
|
+
private registerDefaultRules;
|
|
62
|
+
/**
|
|
63
|
+
* Get all registered rules
|
|
64
|
+
*/
|
|
65
|
+
getRules(): ValidationRule[];
|
|
66
|
+
/**
|
|
67
|
+
* Get rule by ID
|
|
68
|
+
*/
|
|
69
|
+
getRule(id: string): ValidationRule | undefined;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/fix/validation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,GAAG,E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B,CAAC;IAS5B;;OAEG;IACG,YAAY,CAChB,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,IAAI,CAAC,iBAAiB,EAAE,KAAK,CAAC,GACtC,OAAO,CAAC,gBAAgB,CAAC;IAS5B;;OAEG;IACH,OAAO,CAAC,QAAQ;IAmChB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAgM5B;;OAEG;IACH,QAAQ,IAAI,cAAc,EAAE;IAI5B;;OAEG;IACH,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;CAGhD"}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Fix Validation Framework
|
|
4
|
+
*
|
|
5
|
+
* Provides comprehensive validation before and after fix application,
|
|
6
|
+
* including pre-checks, post-checks, and continuous validation.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.FixValidator = void 0;
|
|
10
|
+
const fs_1 = require("fs");
|
|
11
|
+
class FixValidator {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.rules = new Map();
|
|
14
|
+
this.registerDefaultRules();
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Register a validation rule
|
|
18
|
+
*/
|
|
19
|
+
registerRule(rule) {
|
|
20
|
+
this.rules.set(rule.id, rule);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Validate a fix before application
|
|
24
|
+
*/
|
|
25
|
+
async validatePre(fix, context) {
|
|
26
|
+
const validationContext = {
|
|
27
|
+
fix,
|
|
28
|
+
...context,
|
|
29
|
+
};
|
|
30
|
+
return this.validate(validationContext);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Validate a fix after application
|
|
34
|
+
*/
|
|
35
|
+
async validatePost(fix, context) {
|
|
36
|
+
const validationContext = {
|
|
37
|
+
fix,
|
|
38
|
+
...context,
|
|
39
|
+
};
|
|
40
|
+
return this.validate(validationContext, true);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Validate using all rules
|
|
44
|
+
*/
|
|
45
|
+
validate(context, isPost = false) {
|
|
46
|
+
const results = [];
|
|
47
|
+
const errors = [];
|
|
48
|
+
const warnings = [];
|
|
49
|
+
for (const rule of this.rules.values()) {
|
|
50
|
+
const result = rule.validate(context);
|
|
51
|
+
results.push({ rule, result });
|
|
52
|
+
if (!result.passed) {
|
|
53
|
+
if (result.severity === 'error') {
|
|
54
|
+
errors.push(result);
|
|
55
|
+
}
|
|
56
|
+
else if (result.severity === 'warning') {
|
|
57
|
+
warnings.push(result);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const passed = results.filter((r) => r.result.passed).length;
|
|
62
|
+
const failed = results.length - passed;
|
|
63
|
+
return {
|
|
64
|
+
overall: errors.length === 0,
|
|
65
|
+
rules: results,
|
|
66
|
+
errors,
|
|
67
|
+
warnings,
|
|
68
|
+
passed,
|
|
69
|
+
failed,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Register default validation rules
|
|
74
|
+
*/
|
|
75
|
+
registerDefaultRules() {
|
|
76
|
+
// File exists check
|
|
77
|
+
this.registerRule({
|
|
78
|
+
id: 'file-exists',
|
|
79
|
+
name: 'File Exists',
|
|
80
|
+
description: 'Verify target file exists',
|
|
81
|
+
severity: 'error',
|
|
82
|
+
validate: (context) => {
|
|
83
|
+
if (!(0, fs_1.existsSync)(context.filePath)) {
|
|
84
|
+
return {
|
|
85
|
+
passed: false,
|
|
86
|
+
message: `File does not exist: ${context.filePath}`,
|
|
87
|
+
severity: 'error',
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return { passed: true };
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
// Line number validation
|
|
94
|
+
this.registerRule({
|
|
95
|
+
id: 'line-number-valid',
|
|
96
|
+
name: 'Valid Line Number',
|
|
97
|
+
description: 'Verify line number is within file bounds',
|
|
98
|
+
severity: 'error',
|
|
99
|
+
validate: (context) => {
|
|
100
|
+
const lines = context.fileContent.split('\n');
|
|
101
|
+
if (context.fix.line <= 0 || context.fix.line > lines.length) {
|
|
102
|
+
return {
|
|
103
|
+
passed: false,
|
|
104
|
+
message: `Invalid line number: ${context.fix.line} (file has ${lines.length} lines)`,
|
|
105
|
+
severity: 'error',
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
return { passed: true };
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
// Code match validation
|
|
112
|
+
this.registerRule({
|
|
113
|
+
id: 'code-matches',
|
|
114
|
+
name: 'Code Matches',
|
|
115
|
+
description: 'Verify old code matches current file content',
|
|
116
|
+
severity: 'error',
|
|
117
|
+
validate: (context) => {
|
|
118
|
+
const lines = context.fileContent.split('\n');
|
|
119
|
+
const actualLine = lines[context.fix.line - 1];
|
|
120
|
+
if (actualLine.trim() !== context.fix.oldCode.trim()) {
|
|
121
|
+
return {
|
|
122
|
+
passed: false,
|
|
123
|
+
message: `Code mismatch at line ${context.fix.line}`,
|
|
124
|
+
severity: 'error',
|
|
125
|
+
details: {
|
|
126
|
+
expected: context.fix.oldCode.trim(),
|
|
127
|
+
actual: actualLine.trim(),
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
return { passed: true };
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
// Confidence threshold
|
|
135
|
+
this.registerRule({
|
|
136
|
+
id: 'confidence-threshold',
|
|
137
|
+
name: 'Confidence Threshold',
|
|
138
|
+
description: 'Verify fix confidence meets minimum threshold',
|
|
139
|
+
severity: 'warning',
|
|
140
|
+
validate: (context) => {
|
|
141
|
+
if (context.fix.confidence < 0.7) {
|
|
142
|
+
return {
|
|
143
|
+
passed: false,
|
|
144
|
+
message: `Low confidence fix (${(context.fix.confidence * 100).toFixed(0)}%)`,
|
|
145
|
+
severity: 'warning',
|
|
146
|
+
details: { confidence: context.fix.confidence },
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
return { passed: true };
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
// Risk assessment
|
|
153
|
+
this.registerRule({
|
|
154
|
+
id: 'risk-assessment',
|
|
155
|
+
name: 'Risk Assessment',
|
|
156
|
+
description: 'Warn about high-risk fixes',
|
|
157
|
+
severity: 'warning',
|
|
158
|
+
validate: (context) => {
|
|
159
|
+
if (context.fix.risk === 'high') {
|
|
160
|
+
return {
|
|
161
|
+
passed: false,
|
|
162
|
+
message: 'High-risk fix - review carefully',
|
|
163
|
+
severity: 'warning',
|
|
164
|
+
details: { risk: context.fix.risk },
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
return { passed: true };
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
// Syntax validation (basic)
|
|
171
|
+
this.registerRule({
|
|
172
|
+
id: 'syntax-basic',
|
|
173
|
+
name: 'Basic Syntax Check',
|
|
174
|
+
description: 'Basic syntax validation of new code',
|
|
175
|
+
severity: 'warning',
|
|
176
|
+
validate: (context) => {
|
|
177
|
+
const newCode = context.fix.newCode;
|
|
178
|
+
// Check for balanced brackets
|
|
179
|
+
const brackets = { '(': ')', '[': ']', '{': '}' };
|
|
180
|
+
const stack = [];
|
|
181
|
+
for (const char of newCode) {
|
|
182
|
+
if (brackets[char]) {
|
|
183
|
+
stack.push(brackets[char]);
|
|
184
|
+
}
|
|
185
|
+
else if (Object.values(brackets).includes(char)) {
|
|
186
|
+
const expected = stack.pop();
|
|
187
|
+
if (expected !== char) {
|
|
188
|
+
return {
|
|
189
|
+
passed: false,
|
|
190
|
+
message: 'Unbalanced brackets in new code',
|
|
191
|
+
severity: 'warning',
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (stack.length > 0) {
|
|
197
|
+
return {
|
|
198
|
+
passed: false,
|
|
199
|
+
message: 'Unbalanced brackets in new code',
|
|
200
|
+
severity: 'warning',
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
return { passed: true };
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
// File size check
|
|
207
|
+
this.registerRule({
|
|
208
|
+
id: 'file-size',
|
|
209
|
+
name: 'File Size Check',
|
|
210
|
+
description: 'Warn about very large files',
|
|
211
|
+
severity: 'info',
|
|
212
|
+
validate: (context) => {
|
|
213
|
+
const lines = context.fileContent.split('\n');
|
|
214
|
+
if (lines.length > 5000) {
|
|
215
|
+
return {
|
|
216
|
+
passed: false,
|
|
217
|
+
message: `Large file (${lines.length} lines) - fix application may be slow`,
|
|
218
|
+
severity: 'info',
|
|
219
|
+
details: { lineCount: lines.length },
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
return { passed: true };
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
// Dependency conflict check
|
|
226
|
+
this.registerRule({
|
|
227
|
+
id: 'dependency-conflict',
|
|
228
|
+
name: 'Dependency Conflict',
|
|
229
|
+
description: 'Check for dependency conflicts',
|
|
230
|
+
severity: 'warning',
|
|
231
|
+
validate: (context) => {
|
|
232
|
+
if (context.fix.file === 'package.json') {
|
|
233
|
+
// Check if this fix conflicts with other fixes
|
|
234
|
+
for (const pack of context.packs) {
|
|
235
|
+
for (const otherFix of pack.fixes) {
|
|
236
|
+
if (otherFix.findingId !== context.fix.findingId &&
|
|
237
|
+
otherFix.file === 'package.json') {
|
|
238
|
+
// Both modify package.json - potential conflict
|
|
239
|
+
return {
|
|
240
|
+
passed: false,
|
|
241
|
+
message: 'Multiple package.json fixes - potential conflict',
|
|
242
|
+
severity: 'warning',
|
|
243
|
+
details: { conflictingFix: otherFix.findingId },
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return { passed: true };
|
|
250
|
+
},
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Get all registered rules
|
|
255
|
+
*/
|
|
256
|
+
getRules() {
|
|
257
|
+
return Array.from(this.rules.values());
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Get rule by ID
|
|
261
|
+
*/
|
|
262
|
+
getRule(id) {
|
|
263
|
+
return this.rules.get(id);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
exports.FixValidator = FixValidator;
|
|
267
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/fix/validation.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,2BAA8C;AAsC9C,MAAa,YAAY;IAGvB;QAFQ,UAAK,GAAgC,IAAI,GAAG,EAAE,CAAC;QAGrD,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,IAAoB;QAC/B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CACf,GAAQ,EACR,OAAuC;QAEvC,MAAM,iBAAiB,GAAsB;YAC3C,GAAG;YACH,GAAG,OAAO;SACX,CAAC;QAEF,OAAO,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,YAAY,CAChB,GAAQ,EACR,OAAuC;QAEvC,MAAM,iBAAiB,GAAsB;YAC3C,GAAG;YACH,GAAG,OAAO;SACX,CAAC;QAEF,OAAO,IAAI,CAAC,QAAQ,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACK,QAAQ,CACd,OAA0B,EAC1B,SAAkB,KAAK;QAEvB,MAAM,OAAO,GACX,EAAE,CAAC;QACL,MAAM,MAAM,GAAuB,EAAE,CAAC;QACtC,MAAM,QAAQ,GAAuB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CAAC,KAAK,EAAE,CAAC;wBACjC,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;4BAClC,IACE,QAAQ,CAAC,SAAS,KAAK,OAAO,CAAC,GAAG,CAAC,SAAS;gCAC5C,QAAQ,CAAC,IAAI,KAAK,cAAc,EAChC,CAAC;gCACD,gDAAgD;gCAChD,OAAO;oCACL,MAAM,EAAE,KAAK;oCACb,OAAO,EAAE,kDAAkD;oCAC3D,QAAQ,EAAE,SAAS;oCACnB,OAAO,EAAE,EAAE,cAAc,EAAE,QAAQ,CAAC,SAAS,EAAE;iCAChD,CAAC;4BACJ,CAAC;wBACH,CAAC;oBACH,CAAC;gBACH,CAAC;gBACD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;YAC1B,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,EAAU;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;CACF;AAlSD,oCAkSC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Advanced Diff Visualization
|
|
3
|
+
*
|
|
4
|
+
* Provides enhanced diff visualization with syntax highlighting,
|
|
5
|
+
* context lines, and interactive preview capabilities.
|
|
6
|
+
*/
|
|
7
|
+
import { FixPack } from './engine';
|
|
8
|
+
export interface DiffVisualization {
|
|
9
|
+
files: DiffFile[];
|
|
10
|
+
summary: {
|
|
11
|
+
totalFiles: number;
|
|
12
|
+
totalAdditions: number;
|
|
13
|
+
totalDeletions: number;
|
|
14
|
+
totalChanges: number;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface DiffFile {
|
|
18
|
+
file: string;
|
|
19
|
+
hunks: DiffHunk[];
|
|
20
|
+
summary: {
|
|
21
|
+
additions: number;
|
|
22
|
+
deletions: number;
|
|
23
|
+
changes: number;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export interface DiffHunk {
|
|
27
|
+
oldStart: number;
|
|
28
|
+
oldLines: number;
|
|
29
|
+
newStart: number;
|
|
30
|
+
newLines: number;
|
|
31
|
+
context: string[];
|
|
32
|
+
changes: DiffChange[];
|
|
33
|
+
}
|
|
34
|
+
export interface DiffChange {
|
|
35
|
+
type: 'add' | 'delete' | 'context';
|
|
36
|
+
line: string;
|
|
37
|
+
oldLineNumber?: number;
|
|
38
|
+
newLineNumber?: number;
|
|
39
|
+
}
|
|
40
|
+
export declare class DiffVisualizer {
|
|
41
|
+
private projectPath;
|
|
42
|
+
private contextLines;
|
|
43
|
+
constructor(projectPath: string, contextLines?: number);
|
|
44
|
+
/**
|
|
45
|
+
* Generate unified diff visualization
|
|
46
|
+
*/
|
|
47
|
+
visualize(packs: FixPack[]): DiffVisualization;
|
|
48
|
+
/**
|
|
49
|
+
* Create a hunk for a single fix
|
|
50
|
+
*/
|
|
51
|
+
private createHunk;
|
|
52
|
+
/**
|
|
53
|
+
* Generate unified diff string (compatible with git diff)
|
|
54
|
+
*/
|
|
55
|
+
generateUnifiedDiff(packs: FixPack[]): string;
|
|
56
|
+
/**
|
|
57
|
+
* Generate colored terminal output
|
|
58
|
+
*/
|
|
59
|
+
generateColoredDiff(packs: FixPack[]): string;
|
|
60
|
+
/**
|
|
61
|
+
* Generate HTML diff
|
|
62
|
+
*/
|
|
63
|
+
generateHTMLDiff(packs: FixPack[]): string;
|
|
64
|
+
/**
|
|
65
|
+
* Get HTML styles for diff
|
|
66
|
+
*/
|
|
67
|
+
private getHTMLStyles;
|
|
68
|
+
/**
|
|
69
|
+
* Escape HTML entities
|
|
70
|
+
*/
|
|
71
|
+
private escapeHtml;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=visualization.d.ts.map
|