@vibecheckai/cli 3.5.0 → 3.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/bin/registry.js +174 -449
- package/bin/runners/cli-utils.js +33 -2
- package/bin/runners/context/generators/cursor.js +2 -49
- package/bin/runners/context/generators/mcp.js +13 -15
- package/bin/runners/context/proof-context.js +1 -248
- package/bin/runners/lib/analysis-core.js +180 -198
- package/bin/runners/lib/analyzers.js +241 -2212
- package/bin/runners/lib/cli-output.js +210 -242
- package/bin/runners/lib/detectors-v2.js +785 -547
- package/bin/runners/lib/entitlements-v2.js +431 -161
- package/bin/runners/lib/error-handler.js +9 -16
- package/bin/runners/lib/global-flags.js +0 -37
- package/bin/runners/lib/html-proof-report.js +700 -350
- package/bin/runners/lib/missions/plan.js +6 -46
- package/bin/runners/lib/missions/templates.js +0 -232
- package/bin/runners/lib/route-truth.js +322 -1167
- package/bin/runners/lib/scan-output.js +467 -493
- package/bin/runners/lib/ship-output.js +27 -280
- package/bin/runners/lib/terminal-ui.js +700 -310
- package/bin/runners/lib/truth.js +321 -1004
- package/bin/runners/lib/unified-output.js +158 -162
- package/bin/runners/lib/upsell.js +204 -104
- package/bin/runners/runAIAgent.js +10 -5
- package/bin/runners/runAllowlist.js +324 -0
- package/bin/runners/runAuth.js +94 -344
- package/bin/runners/runCheckpoint.js +45 -43
- package/bin/runners/runContext.js +24 -139
- package/bin/runners/runDoctor.js +101 -136
- package/bin/runners/runEvidencePack.js +219 -0
- package/bin/runners/runFix.js +71 -82
- package/bin/runners/runGuard.js +119 -606
- package/bin/runners/runInit.js +60 -22
- package/bin/runners/runInstall.js +281 -0
- package/bin/runners/runLabs.js +341 -0
- package/bin/runners/runMcp.js +62 -139
- package/bin/runners/runPolish.js +83 -282
- package/bin/runners/runPromptFirewall.js +12 -5
- package/bin/runners/runProve.js +58 -33
- package/bin/runners/runReality.js +58 -81
- package/bin/runners/runReport.js +7 -34
- package/bin/runners/runRuntime.js +8 -5
- package/bin/runners/runScan.js +844 -219
- package/bin/runners/runShip.js +59 -721
- package/bin/runners/runValidate.js +11 -24
- package/bin/runners/runWatch.js +76 -131
- package/bin/vibecheck.js +69 -295
- package/mcp-server/ARCHITECTURE.md +339 -0
- package/mcp-server/__tests__/cache.test.ts +313 -0
- package/mcp-server/__tests__/executor.test.ts +239 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/.cache/webpack/cache.pack +1 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/.next/server/chunk.js +3 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/.turbo/cache.json +3 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/.venv/lib/env.py +3 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/dist/bundle.js +3 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/package.json +5 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/src/app.ts +5 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/venv/lib/config.py +4 -0
- package/mcp-server/__tests__/ids.test.ts +345 -0
- package/mcp-server/__tests__/integration/tools.test.ts +410 -0
- package/mcp-server/__tests__/registry.test.ts +365 -0
- package/mcp-server/__tests__/sandbox.test.ts +323 -0
- package/mcp-server/__tests__/schemas.test.ts +372 -0
- package/mcp-server/benchmarks/run-benchmarks.ts +304 -0
- package/mcp-server/examples/doctor.request.json +14 -0
- package/mcp-server/examples/doctor.response.json +53 -0
- package/mcp-server/examples/error.response.json +15 -0
- package/mcp-server/examples/scan.request.json +14 -0
- package/mcp-server/examples/scan.response.json +108 -0
- package/mcp-server/handlers/tool-handler.ts +671 -0
- package/mcp-server/index-v1.js +698 -0
- package/mcp-server/index-v3.ts +293 -0
- package/mcp-server/index.js +1080 -1757
- package/mcp-server/index.old.js +4137 -0
- package/mcp-server/lib/cache.ts +341 -0
- package/mcp-server/lib/errors.ts +346 -0
- package/mcp-server/lib/executor.ts +792 -0
- package/mcp-server/lib/ids.ts +238 -0
- package/mcp-server/lib/logger.ts +368 -0
- package/mcp-server/lib/metrics.ts +365 -0
- package/mcp-server/lib/sandbox.ts +337 -0
- package/mcp-server/lib/validator.ts +229 -0
- package/mcp-server/package-lock.json +165 -0
- package/mcp-server/package.json +32 -7
- package/mcp-server/premium-tools.js +2 -2
- package/mcp-server/registry/tools.json +476 -0
- package/mcp-server/schemas/error-envelope.schema.json +125 -0
- package/mcp-server/schemas/finding.schema.json +167 -0
- package/mcp-server/schemas/report-artifact.schema.json +88 -0
- package/mcp-server/schemas/run-request.schema.json +75 -0
- package/mcp-server/schemas/verdict.schema.json +168 -0
- package/mcp-server/tier-auth.d.ts +71 -0
- package/mcp-server/tier-auth.js +371 -183
- package/mcp-server/truth-context.js +90 -131
- package/mcp-server/truth-firewall-tools.js +1000 -1611
- package/mcp-server/tsconfig.json +34 -0
- package/mcp-server/vibecheck-tools.js +2 -2
- package/mcp-server/vitest.config.ts +16 -0
- package/package.json +3 -4
- package/bin/runners/lib/agent-firewall/ai/false-positive-analyzer.js +0 -474
- package/bin/runners/lib/agent-firewall/change-packet/builder.js +0 -488
- package/bin/runners/lib/agent-firewall/change-packet/schema.json +0 -228
- package/bin/runners/lib/agent-firewall/change-packet/store.js +0 -200
- package/bin/runners/lib/agent-firewall/claims/claim-types.js +0 -21
- package/bin/runners/lib/agent-firewall/claims/extractor.js +0 -303
- package/bin/runners/lib/agent-firewall/claims/patterns.js +0 -24
- package/bin/runners/lib/agent-firewall/critic/index.js +0 -151
- package/bin/runners/lib/agent-firewall/critic/judge.js +0 -432
- package/bin/runners/lib/agent-firewall/critic/prompts.js +0 -305
- package/bin/runners/lib/agent-firewall/evidence/auth-evidence.js +0 -88
- package/bin/runners/lib/agent-firewall/evidence/contract-evidence.js +0 -75
- package/bin/runners/lib/agent-firewall/evidence/env-evidence.js +0 -127
- package/bin/runners/lib/agent-firewall/evidence/resolver.js +0 -102
- package/bin/runners/lib/agent-firewall/evidence/route-evidence.js +0 -213
- package/bin/runners/lib/agent-firewall/evidence/side-effect-evidence.js +0 -145
- package/bin/runners/lib/agent-firewall/fs-hook/daemon.js +0 -19
- package/bin/runners/lib/agent-firewall/fs-hook/installer.js +0 -87
- package/bin/runners/lib/agent-firewall/fs-hook/watcher.js +0 -184
- package/bin/runners/lib/agent-firewall/git-hook/pre-commit.js +0 -163
- package/bin/runners/lib/agent-firewall/ide-extension/cursor.js +0 -107
- package/bin/runners/lib/agent-firewall/ide-extension/vscode.js +0 -68
- package/bin/runners/lib/agent-firewall/ide-extension/windsurf.js +0 -66
- package/bin/runners/lib/agent-firewall/interceptor/base.js +0 -304
- package/bin/runners/lib/agent-firewall/interceptor/cursor.js +0 -35
- package/bin/runners/lib/agent-firewall/interceptor/vscode.js +0 -35
- package/bin/runners/lib/agent-firewall/interceptor/windsurf.js +0 -34
- package/bin/runners/lib/agent-firewall/lawbook/distributor.js +0 -465
- package/bin/runners/lib/agent-firewall/lawbook/evaluator.js +0 -604
- package/bin/runners/lib/agent-firewall/lawbook/index.js +0 -304
- package/bin/runners/lib/agent-firewall/lawbook/registry.js +0 -514
- package/bin/runners/lib/agent-firewall/lawbook/schema.js +0 -420
- package/bin/runners/lib/agent-firewall/learning/learning-engine.js +0 -849
- package/bin/runners/lib/agent-firewall/logger.js +0 -141
- package/bin/runners/lib/agent-firewall/policy/default-policy.json +0 -90
- package/bin/runners/lib/agent-firewall/policy/engine.js +0 -103
- package/bin/runners/lib/agent-firewall/policy/loader.js +0 -451
- package/bin/runners/lib/agent-firewall/policy/rules/auth-drift.js +0 -50
- package/bin/runners/lib/agent-firewall/policy/rules/contract-drift.js +0 -50
- package/bin/runners/lib/agent-firewall/policy/rules/fake-success.js +0 -86
- package/bin/runners/lib/agent-firewall/policy/rules/ghost-env.js +0 -162
- package/bin/runners/lib/agent-firewall/policy/rules/ghost-route.js +0 -189
- package/bin/runners/lib/agent-firewall/policy/rules/scope.js +0 -93
- package/bin/runners/lib/agent-firewall/policy/rules/unsafe-side-effect.js +0 -57
- package/bin/runners/lib/agent-firewall/policy/schema.json +0 -183
- package/bin/runners/lib/agent-firewall/policy/verdict.js +0 -54
- package/bin/runners/lib/agent-firewall/proposal/extractor.js +0 -394
- package/bin/runners/lib/agent-firewall/proposal/index.js +0 -212
- package/bin/runners/lib/agent-firewall/proposal/schema.js +0 -251
- package/bin/runners/lib/agent-firewall/proposal/validator.js +0 -386
- package/bin/runners/lib/agent-firewall/reality/index.js +0 -332
- package/bin/runners/lib/agent-firewall/reality/state.js +0 -625
- package/bin/runners/lib/agent-firewall/reality/watcher.js +0 -322
- package/bin/runners/lib/agent-firewall/risk/index.js +0 -173
- package/bin/runners/lib/agent-firewall/risk/scorer.js +0 -328
- package/bin/runners/lib/agent-firewall/risk/thresholds.js +0 -321
- package/bin/runners/lib/agent-firewall/risk/vectors.js +0 -421
- package/bin/runners/lib/agent-firewall/simulator/diff-simulator.js +0 -472
- package/bin/runners/lib/agent-firewall/simulator/import-resolver.js +0 -346
- package/bin/runners/lib/agent-firewall/simulator/index.js +0 -181
- package/bin/runners/lib/agent-firewall/simulator/route-validator.js +0 -380
- package/bin/runners/lib/agent-firewall/time-machine/incident-correlator.js +0 -661
- package/bin/runners/lib/agent-firewall/time-machine/index.js +0 -267
- package/bin/runners/lib/agent-firewall/time-machine/replay-engine.js +0 -436
- package/bin/runners/lib/agent-firewall/time-machine/state-reconstructor.js +0 -490
- package/bin/runners/lib/agent-firewall/time-machine/timeline-builder.js +0 -530
- package/bin/runners/lib/agent-firewall/truthpack/index.js +0 -67
- package/bin/runners/lib/agent-firewall/truthpack/loader.js +0 -137
- package/bin/runners/lib/agent-firewall/unblock/planner.js +0 -337
- package/bin/runners/lib/agent-firewall/utils/ignore-checker.js +0 -118
- package/bin/runners/lib/api-client.js +0 -269
- package/bin/runners/lib/audit-logger.js +0 -532
- package/bin/runners/lib/authority/authorities/architecture.js +0 -364
- package/bin/runners/lib/authority/authorities/compliance.js +0 -341
- package/bin/runners/lib/authority/authorities/human.js +0 -343
- package/bin/runners/lib/authority/authorities/quality.js +0 -420
- package/bin/runners/lib/authority/authorities/security.js +0 -228
- package/bin/runners/lib/authority/index.js +0 -293
- package/bin/runners/lib/authority-badge.js +0 -425
- package/bin/runners/lib/bundle/bundle-intelligence.js +0 -846
- package/bin/runners/lib/cli-charts.js +0 -368
- package/bin/runners/lib/cli-config-display.js +0 -405
- package/bin/runners/lib/cli-demo.js +0 -275
- package/bin/runners/lib/cli-errors.js +0 -438
- package/bin/runners/lib/cli-help-formatter.js +0 -439
- package/bin/runners/lib/cli-interactive-menu.js +0 -509
- package/bin/runners/lib/cli-prompts.js +0 -441
- package/bin/runners/lib/cli-scan-cards.js +0 -362
- package/bin/runners/lib/compliance-reporter.js +0 -710
- package/bin/runners/lib/conductor/index.js +0 -671
- package/bin/runners/lib/easy/README.md +0 -123
- package/bin/runners/lib/easy/index.js +0 -140
- package/bin/runners/lib/easy/interactive-wizard.js +0 -788
- package/bin/runners/lib/easy/one-click-firewall.js +0 -564
- package/bin/runners/lib/easy/zero-config-reality.js +0 -714
- package/bin/runners/lib/engines/accessibility-engine.js +0 -390
- package/bin/runners/lib/engines/api-consistency-engine.js +0 -467
- package/bin/runners/lib/engines/ast-cache.js +0 -99
- package/bin/runners/lib/engines/async-patterns-engine.js +0 -444
- package/bin/runners/lib/engines/bundle-size-engine.js +0 -433
- package/bin/runners/lib/engines/code-quality-engine.js +0 -255
- package/bin/runners/lib/engines/confidence-scoring.js +0 -276
- package/bin/runners/lib/engines/console-logs-engine.js +0 -115
- package/bin/runners/lib/engines/context-detection.js +0 -264
- package/bin/runners/lib/engines/cross-file-analysis-engine.js +0 -533
- package/bin/runners/lib/engines/database-patterns-engine.js +0 -429
- package/bin/runners/lib/engines/dead-code-engine.js +0 -198
- package/bin/runners/lib/engines/deprecated-api-engine.js +0 -226
- package/bin/runners/lib/engines/duplicate-code-engine.js +0 -354
- package/bin/runners/lib/engines/empty-catch-engine.js +0 -260
- package/bin/runners/lib/engines/env-variables-engine.js +0 -458
- package/bin/runners/lib/engines/error-handling-engine.js +0 -437
- package/bin/runners/lib/engines/false-positive-prevention.js +0 -630
- package/bin/runners/lib/engines/file-filter.js +0 -131
- package/bin/runners/lib/engines/framework-adapters/index.js +0 -607
- package/bin/runners/lib/engines/framework-detection.js +0 -508
- package/bin/runners/lib/engines/hardcoded-secrets-engine.js +0 -251
- package/bin/runners/lib/engines/import-order-engine.js +0 -429
- package/bin/runners/lib/engines/mock-data-engine.js +0 -315
- package/bin/runners/lib/engines/naming-conventions-engine.js +0 -544
- package/bin/runners/lib/engines/noise-reduction-engine.js +0 -452
- package/bin/runners/lib/engines/orchestrator.js +0 -334
- package/bin/runners/lib/engines/parallel-processor.js +0 -71
- package/bin/runners/lib/engines/performance-issues-engine.js +0 -405
- package/bin/runners/lib/engines/react-patterns-engine.js +0 -457
- package/bin/runners/lib/engines/security-vulnerabilities-engine.js +0 -571
- package/bin/runners/lib/engines/todo-fixme-engine.js +0 -115
- package/bin/runners/lib/engines/type-aware-engine.js +0 -376
- package/bin/runners/lib/engines/unsafe-regex-engine.js +0 -225
- package/bin/runners/lib/engines/vibecheck-engines/README.md +0 -53
- package/bin/runners/lib/engines/vibecheck-engines/index.js +0 -124
- package/bin/runners/lib/engines/vibecheck-engines/lib/ai-hallucination-engine.js +0 -806
- package/bin/runners/lib/engines/vibecheck-engines/lib/hardcoded-secrets-engine.js +0 -439
- package/bin/runners/lib/engines/vibecheck-engines/lib/smart-fix-engine.js +0 -577
- package/bin/runners/lib/engines/vibecheck-engines/lib/vibe-score-engine.js +0 -543
- package/bin/runners/lib/engines/vibecheck-engines/package.json +0 -13
- package/bin/runners/lib/engines/vibecheck-engines.js +0 -514
- package/bin/runners/lib/enhanced-features/index.js +0 -305
- package/bin/runners/lib/enhanced-output.js +0 -631
- package/bin/runners/lib/enterprise.js +0 -300
- package/bin/runners/lib/exit-codes.js +0 -275
- package/bin/runners/lib/fingerprint.js +0 -377
- package/bin/runners/lib/firewall/command-validator.js +0 -351
- package/bin/runners/lib/firewall/config.js +0 -341
- package/bin/runners/lib/firewall/content-validator.js +0 -519
- package/bin/runners/lib/firewall/index.js +0 -101
- package/bin/runners/lib/firewall/path-validator.js +0 -256
- package/bin/runners/lib/help-formatter.js +0 -413
- package/bin/runners/lib/intelligence/cross-repo-intelligence.js +0 -817
- package/bin/runners/lib/logger.js +0 -38
- package/bin/runners/lib/mcp-utils.js +0 -425
- package/bin/runners/lib/output/index.js +0 -1022
- package/bin/runners/lib/policy-engine.js +0 -652
- package/bin/runners/lib/polish/autofix/accessibility-fixes.js +0 -333
- package/bin/runners/lib/polish/autofix/async-handlers.js +0 -273
- package/bin/runners/lib/polish/autofix/dead-code.js +0 -280
- package/bin/runners/lib/polish/autofix/imports-optimizer.js +0 -344
- package/bin/runners/lib/polish/autofix/index.js +0 -200
- package/bin/runners/lib/polish/autofix/remove-consoles.js +0 -209
- package/bin/runners/lib/polish/autofix/strengthen-types.js +0 -245
- package/bin/runners/lib/polish/backend-checks.js +0 -148
- package/bin/runners/lib/polish/documentation-checks.js +0 -111
- package/bin/runners/lib/polish/frontend-checks.js +0 -168
- package/bin/runners/lib/polish/index.js +0 -71
- package/bin/runners/lib/polish/infrastructure-checks.js +0 -131
- package/bin/runners/lib/polish/library-detection.js +0 -175
- package/bin/runners/lib/polish/performance-checks.js +0 -100
- package/bin/runners/lib/polish/security-checks.js +0 -148
- package/bin/runners/lib/polish/utils.js +0 -203
- package/bin/runners/lib/prompt-builder.js +0 -540
- package/bin/runners/lib/proof-certificate.js +0 -634
- package/bin/runners/lib/reality/accessibility-audit.js +0 -946
- package/bin/runners/lib/reality/api-contract-validator.js +0 -1012
- package/bin/runners/lib/reality/chaos-engineering.js +0 -1084
- package/bin/runners/lib/reality/performance-tracker.js +0 -1077
- package/bin/runners/lib/reality/scenario-generator.js +0 -1404
- package/bin/runners/lib/reality/visual-regression.js +0 -852
- package/bin/runners/lib/reality-profiler.js +0 -717
- package/bin/runners/lib/replay/flight-recorder-viewer.js +0 -1160
- package/bin/runners/lib/review/ai-code-review.js +0 -832
- package/bin/runners/lib/rules/custom-rule-engine.js +0 -985
- package/bin/runners/lib/sbom-generator.js +0 -641
- package/bin/runners/lib/scan-output-enhanced.js +0 -512
- package/bin/runners/lib/security/owasp-scanner.js +0 -939
- package/bin/runners/lib/ship-output-enterprise.js +0 -239
- package/bin/runners/lib/unified-cli-output.js +0 -777
- package/bin/runners/lib/validators/contract-validator.js +0 -283
- package/bin/runners/lib/validators/dead-export-detector.js +0 -279
- package/bin/runners/lib/validators/dep-audit.js +0 -245
- package/bin/runners/lib/validators/env-validator.js +0 -319
- package/bin/runners/lib/validators/index.js +0 -120
- package/bin/runners/lib/validators/license-checker.js +0 -252
- package/bin/runners/lib/validators/route-validator.js +0 -290
- package/bin/runners/runAgent.d.ts +0 -5
- package/bin/runners/runAgent.js +0 -164
- package/bin/runners/runApprove.js +0 -1233
- package/bin/runners/runAuthority.js +0 -528
- package/bin/runners/runClassify.js +0 -862
- package/bin/runners/runConductor.js +0 -772
- package/bin/runners/runContainer.js +0 -366
- package/bin/runners/runContext.d.ts +0 -4
- package/bin/runners/runEasy.js +0 -410
- package/bin/runners/runFirewall.d.ts +0 -5
- package/bin/runners/runFirewall.js +0 -137
- package/bin/runners/runFirewallHook.d.ts +0 -5
- package/bin/runners/runFirewallHook.js +0 -59
- package/bin/runners/runIaC.js +0 -372
- package/bin/runners/runPolish.d.ts +0 -4
- package/bin/runners/runProof.zip +0 -0
- package/bin/runners/runTruth.d.ts +0 -5
- package/bin/runners/runTruth.js +0 -104
- package/bin/runners/runVibe.js +0 -791
- package/mcp-server/HARDENING_SUMMARY.md +0 -299
- package/mcp-server/agent-firewall-interceptor.js +0 -500
- package/mcp-server/authority-tools.js +0 -569
- package/mcp-server/conductor/conflict-resolver.js +0 -588
- package/mcp-server/conductor/execution-planner.js +0 -544
- package/mcp-server/conductor/index.js +0 -377
- package/mcp-server/conductor/lock-manager.js +0 -615
- package/mcp-server/conductor/request-queue.js +0 -550
- package/mcp-server/conductor/session-manager.js +0 -500
- package/mcp-server/conductor/tools.js +0 -510
- package/mcp-server/lib/api-client.cjs +0 -13
- package/mcp-server/lib/logger.cjs +0 -30
- package/mcp-server/logger.js +0 -173
- package/mcp-server/tools-v3.js +0 -1039
- package/mcp-server/tools.js +0 -495
- package/mcp-server/vibecheck-mcp-server-3.2.0.tgz +0 -0
|
@@ -1,420 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lawbook Invariant Schema
|
|
3
|
-
*
|
|
4
|
-
* Defines the YAML DSL for organizational invariant rules.
|
|
5
|
-
* Invariants are rules that must ALWAYS hold true in the codebase.
|
|
6
|
-
*
|
|
7
|
-
* Codename: Lawbook
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
"use strict";
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Invariant rule types
|
|
14
|
-
*/
|
|
15
|
-
const INVARIANT_TYPES = {
|
|
16
|
-
// File/path based rules
|
|
17
|
-
NO_MODIFY: "no-modify", // Files/paths that cannot be modified
|
|
18
|
-
NO_DELETE: "no-delete", // Files/paths that cannot be deleted
|
|
19
|
-
NO_CREATE: "no-create", // Patterns that cannot be created
|
|
20
|
-
REQUIRE_APPROVAL: "require-approval", // Changes require approval
|
|
21
|
-
|
|
22
|
-
// Code pattern rules
|
|
23
|
-
NEVER: "never", // Pattern must never appear
|
|
24
|
-
ALWAYS: "always", // Pattern must always be present
|
|
25
|
-
BEFORE: "before", // Pattern A must come before pattern B
|
|
26
|
-
AFTER: "after", // Pattern A must come after pattern B
|
|
27
|
-
MAINTAINS: "maintains", // Property must be maintained
|
|
28
|
-
|
|
29
|
-
// Architectural rules
|
|
30
|
-
ALL_THROUGH: "all-through", // All X must go through Y
|
|
31
|
-
NO_DIRECT: "no-direct", // No direct access to X (use Y instead)
|
|
32
|
-
LAYER_BOUNDARY: "layer-boundary", // Enforce architectural layers
|
|
33
|
-
|
|
34
|
-
// Environment rules
|
|
35
|
-
ENV_MUST_BE_REGISTERED: "env-must-be-registered", // All env vars must be in registry
|
|
36
|
-
ENV_REQUIRED: "env-required", // Specific env vars required
|
|
37
|
-
|
|
38
|
-
// Dependency rules
|
|
39
|
-
DEPENDENCY_LOCKED: "dependency-locked", // Dependency version locked
|
|
40
|
-
NO_DEPENDENCY: "no-dependency", // Certain dependencies forbidden
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Invariant severity levels
|
|
45
|
-
*/
|
|
46
|
-
const INVARIANT_SEVERITY = {
|
|
47
|
-
BLOCK: "block", // Absolutely cannot proceed
|
|
48
|
-
ERROR: "error", // Serious violation
|
|
49
|
-
WARNING: "warning", // Should be addressed
|
|
50
|
-
INFO: "info", // Advisory
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Invariant scope types
|
|
55
|
-
*/
|
|
56
|
-
const SCOPE_TYPES = {
|
|
57
|
-
FILE: "file", // Single file
|
|
58
|
-
DIRECTORY: "directory", // Directory and subdirectories
|
|
59
|
-
GLOB: "glob", // Glob pattern
|
|
60
|
-
REGEX: "regex", // Regex pattern
|
|
61
|
-
ALL: "all", // Entire codebase
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* JSON Schema for invariant definitions
|
|
66
|
-
*/
|
|
67
|
-
const INVARIANT_SCHEMA = {
|
|
68
|
-
$schema: "http://json-schema.org/draft-07/schema#",
|
|
69
|
-
title: "VibeCheck Lawbook Invariant",
|
|
70
|
-
type: "object",
|
|
71
|
-
required: ["id", "rule"],
|
|
72
|
-
properties: {
|
|
73
|
-
id: {
|
|
74
|
-
type: "string",
|
|
75
|
-
description: "Unique identifier for this invariant",
|
|
76
|
-
pattern: "^[a-z0-9-]+$",
|
|
77
|
-
},
|
|
78
|
-
description: {
|
|
79
|
-
type: "string",
|
|
80
|
-
description: "Human-readable description of this invariant",
|
|
81
|
-
},
|
|
82
|
-
rule: {
|
|
83
|
-
type: "string",
|
|
84
|
-
enum: Object.values(INVARIANT_TYPES),
|
|
85
|
-
description: "Type of invariant rule",
|
|
86
|
-
},
|
|
87
|
-
scope: {
|
|
88
|
-
type: "string",
|
|
89
|
-
description: "Glob pattern defining where this rule applies",
|
|
90
|
-
},
|
|
91
|
-
target: {
|
|
92
|
-
type: "string",
|
|
93
|
-
description: "Target path/file for 'all-through' rules",
|
|
94
|
-
},
|
|
95
|
-
pattern: {
|
|
96
|
-
type: "string",
|
|
97
|
-
description: "Regex pattern to match/exclude",
|
|
98
|
-
},
|
|
99
|
-
exclude: {
|
|
100
|
-
oneOf: [
|
|
101
|
-
{ type: "string" },
|
|
102
|
-
{ type: "array", items: { type: "string" } },
|
|
103
|
-
],
|
|
104
|
-
description: "Paths/patterns excluded from this rule",
|
|
105
|
-
},
|
|
106
|
-
violations: {
|
|
107
|
-
type: "array",
|
|
108
|
-
items: {
|
|
109
|
-
type: "object",
|
|
110
|
-
properties: {
|
|
111
|
-
pattern: { type: "string" },
|
|
112
|
-
exclude: {
|
|
113
|
-
oneOf: [
|
|
114
|
-
{ type: "string" },
|
|
115
|
-
{ type: "array", items: { type: "string" } },
|
|
116
|
-
],
|
|
117
|
-
},
|
|
118
|
-
message: { type: "string" },
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
description: "Specific violation patterns to detect",
|
|
122
|
-
},
|
|
123
|
-
severity: {
|
|
124
|
-
type: "string",
|
|
125
|
-
enum: Object.values(INVARIANT_SEVERITY),
|
|
126
|
-
default: "error",
|
|
127
|
-
description: "Severity level when violated",
|
|
128
|
-
},
|
|
129
|
-
introduced: {
|
|
130
|
-
type: "string",
|
|
131
|
-
format: "date",
|
|
132
|
-
description: "Date this invariant was introduced",
|
|
133
|
-
},
|
|
134
|
-
incident: {
|
|
135
|
-
type: "string",
|
|
136
|
-
description: "Related incident ID that prompted this invariant",
|
|
137
|
-
},
|
|
138
|
-
owner: {
|
|
139
|
-
type: "string",
|
|
140
|
-
description: "Team/person responsible for this invariant",
|
|
141
|
-
},
|
|
142
|
-
registry: {
|
|
143
|
-
type: "string",
|
|
144
|
-
description: "Registry file for env-must-be-registered rules",
|
|
145
|
-
},
|
|
146
|
-
message: {
|
|
147
|
-
type: "string",
|
|
148
|
-
description: "Custom message when violated",
|
|
149
|
-
},
|
|
150
|
-
autofix: {
|
|
151
|
-
type: "object",
|
|
152
|
-
properties: {
|
|
153
|
-
enabled: { type: "boolean", default: false },
|
|
154
|
-
action: { type: "string" },
|
|
155
|
-
template: { type: "string" },
|
|
156
|
-
},
|
|
157
|
-
description: "Auto-fix configuration",
|
|
158
|
-
},
|
|
159
|
-
metadata: {
|
|
160
|
-
type: "object",
|
|
161
|
-
description: "Additional metadata",
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Schema for the full lawbook YAML file
|
|
168
|
-
*/
|
|
169
|
-
const LAWBOOK_FILE_SCHEMA = {
|
|
170
|
-
$schema: "http://json-schema.org/draft-07/schema#",
|
|
171
|
-
title: "VibeCheck Lawbook",
|
|
172
|
-
type: "object",
|
|
173
|
-
properties: {
|
|
174
|
-
version: {
|
|
175
|
-
type: "string",
|
|
176
|
-
default: "1.0.0",
|
|
177
|
-
description: "Lawbook schema version",
|
|
178
|
-
},
|
|
179
|
-
name: {
|
|
180
|
-
type: "string",
|
|
181
|
-
description: "Name of this invariant library",
|
|
182
|
-
},
|
|
183
|
-
description: {
|
|
184
|
-
type: "string",
|
|
185
|
-
description: "Description of this invariant library",
|
|
186
|
-
},
|
|
187
|
-
extends: {
|
|
188
|
-
oneOf: [
|
|
189
|
-
{ type: "string" },
|
|
190
|
-
{ type: "array", items: { type: "string" } },
|
|
191
|
-
],
|
|
192
|
-
description: "Other lawbooks this extends",
|
|
193
|
-
},
|
|
194
|
-
invariants: {
|
|
195
|
-
type: "array",
|
|
196
|
-
items: { $ref: "#/definitions/invariant" },
|
|
197
|
-
description: "List of invariant rules",
|
|
198
|
-
},
|
|
199
|
-
groups: {
|
|
200
|
-
type: "object",
|
|
201
|
-
additionalProperties: {
|
|
202
|
-
type: "array",
|
|
203
|
-
items: { type: "string" },
|
|
204
|
-
},
|
|
205
|
-
description: "Named groups of invariant IDs",
|
|
206
|
-
},
|
|
207
|
-
},
|
|
208
|
-
definitions: {
|
|
209
|
-
invariant: INVARIANT_SCHEMA,
|
|
210
|
-
},
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Create a default invariant template
|
|
215
|
-
* @param {string} id - Invariant ID
|
|
216
|
-
* @param {string} rule - Rule type
|
|
217
|
-
* @returns {Object} Invariant template
|
|
218
|
-
*/
|
|
219
|
-
function createInvariantTemplate(id, rule) {
|
|
220
|
-
return {
|
|
221
|
-
id,
|
|
222
|
-
rule,
|
|
223
|
-
description: "",
|
|
224
|
-
scope: "**/*",
|
|
225
|
-
severity: INVARIANT_SEVERITY.ERROR,
|
|
226
|
-
introduced: new Date().toISOString().split("T")[0],
|
|
227
|
-
metadata: {},
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Validate an invariant against the schema
|
|
233
|
-
* @param {Object} invariant - Invariant to validate
|
|
234
|
-
* @returns {Object} Validation result
|
|
235
|
-
*/
|
|
236
|
-
function validateInvariant(invariant) {
|
|
237
|
-
const errors = [];
|
|
238
|
-
|
|
239
|
-
// Check required fields
|
|
240
|
-
if (!invariant.id) {
|
|
241
|
-
errors.push({ field: "id", message: "Invariant ID is required" });
|
|
242
|
-
} else if (!/^[a-z0-9-]+$/.test(invariant.id)) {
|
|
243
|
-
errors.push({ field: "id", message: "Invariant ID must be lowercase alphanumeric with hyphens" });
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
if (!invariant.rule) {
|
|
247
|
-
errors.push({ field: "rule", message: "Rule type is required" });
|
|
248
|
-
} else if (!Object.values(INVARIANT_TYPES).includes(invariant.rule)) {
|
|
249
|
-
errors.push({ field: "rule", message: `Unknown rule type: ${invariant.rule}` });
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
// Validate severity
|
|
253
|
-
if (invariant.severity && !Object.values(INVARIANT_SEVERITY).includes(invariant.severity)) {
|
|
254
|
-
errors.push({ field: "severity", message: `Unknown severity: ${invariant.severity}` });
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
// Rule-specific validation
|
|
258
|
-
if (invariant.rule === INVARIANT_TYPES.ALL_THROUGH && !invariant.target) {
|
|
259
|
-
errors.push({ field: "target", message: "all-through rules require a target" });
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
if ((invariant.rule === INVARIANT_TYPES.NEVER || invariant.rule === INVARIANT_TYPES.ALWAYS) && !invariant.pattern) {
|
|
263
|
-
errors.push({ field: "pattern", message: `${invariant.rule} rules require a pattern` });
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
if (invariant.rule === INVARIANT_TYPES.ENV_MUST_BE_REGISTERED && !invariant.registry) {
|
|
267
|
-
errors.push({ field: "registry", message: "env-must-be-registered rules require a registry file" });
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
return {
|
|
271
|
-
valid: errors.length === 0,
|
|
272
|
-
errors,
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Parse a lawbook YAML string
|
|
278
|
-
* @param {string} content - YAML content
|
|
279
|
-
* @returns {Object} Parsed lawbook
|
|
280
|
-
*/
|
|
281
|
-
function parseLawbook(content) {
|
|
282
|
-
// Try to use js-yaml if available
|
|
283
|
-
try {
|
|
284
|
-
const yaml = require("js-yaml");
|
|
285
|
-
return yaml.load(content);
|
|
286
|
-
} catch {
|
|
287
|
-
// Fallback: basic YAML-like parsing for simple cases
|
|
288
|
-
return parseSimpleLawbook(content);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* Simple lawbook parser for basic YAML structures
|
|
294
|
-
* @param {string} content - YAML content
|
|
295
|
-
* @returns {Object} Parsed lawbook
|
|
296
|
-
*/
|
|
297
|
-
function parseSimpleLawbook(content) {
|
|
298
|
-
const lines = content.split("\n");
|
|
299
|
-
const lawbook = {
|
|
300
|
-
version: "1.0.0",
|
|
301
|
-
invariants: [],
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
let currentInvariant = null;
|
|
305
|
-
let currentKey = null;
|
|
306
|
-
let indent = 0;
|
|
307
|
-
|
|
308
|
-
for (const line of lines) {
|
|
309
|
-
const trimmed = line.trim();
|
|
310
|
-
|
|
311
|
-
// Skip comments and empty lines
|
|
312
|
-
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
313
|
-
|
|
314
|
-
// Check indent level
|
|
315
|
-
const currentIndent = line.search(/\S/);
|
|
316
|
-
|
|
317
|
-
// Key-value pair
|
|
318
|
-
const kvMatch = trimmed.match(/^(\w+):\s*(.*)$/);
|
|
319
|
-
if (kvMatch) {
|
|
320
|
-
const [, key, value] = kvMatch;
|
|
321
|
-
|
|
322
|
-
if (key === "invariants") {
|
|
323
|
-
// Start of invariants array
|
|
324
|
-
continue;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
if (currentIndent > indent && currentInvariant) {
|
|
328
|
-
// Nested property
|
|
329
|
-
currentInvariant[key] = value || undefined;
|
|
330
|
-
} else {
|
|
331
|
-
// Top-level property
|
|
332
|
-
lawbook[key] = value;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
currentKey = key;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
// Array item
|
|
339
|
-
if (trimmed.startsWith("- ")) {
|
|
340
|
-
const itemContent = trimmed.slice(2).trim();
|
|
341
|
-
|
|
342
|
-
if (itemContent.startsWith("id:")) {
|
|
343
|
-
// New invariant
|
|
344
|
-
if (currentInvariant) {
|
|
345
|
-
lawbook.invariants.push(currentInvariant);
|
|
346
|
-
}
|
|
347
|
-
currentInvariant = { id: itemContent.slice(3).trim() };
|
|
348
|
-
indent = currentIndent;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
// Push last invariant
|
|
354
|
-
if (currentInvariant) {
|
|
355
|
-
lawbook.invariants.push(currentInvariant);
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
return lawbook;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* Serialize a lawbook to YAML string
|
|
363
|
-
* @param {Object} lawbook - Lawbook to serialize
|
|
364
|
-
* @returns {string} YAML string
|
|
365
|
-
*/
|
|
366
|
-
function serializeLawbook(lawbook) {
|
|
367
|
-
try {
|
|
368
|
-
const yaml = require("js-yaml");
|
|
369
|
-
return yaml.dump(lawbook, {
|
|
370
|
-
indent: 2,
|
|
371
|
-
lineWidth: 120,
|
|
372
|
-
noRefs: true,
|
|
373
|
-
});
|
|
374
|
-
} catch {
|
|
375
|
-
// Fallback: simple serialization
|
|
376
|
-
return JSON.stringify(lawbook, null, 2);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* Create a default lawbook template
|
|
382
|
-
* @param {string} name - Lawbook name
|
|
383
|
-
* @returns {Object} Default lawbook
|
|
384
|
-
*/
|
|
385
|
-
function createDefaultLawbook(name = "project-invariants") {
|
|
386
|
-
return {
|
|
387
|
-
version: "1.0.0",
|
|
388
|
-
name,
|
|
389
|
-
description: "Project-specific invariant rules",
|
|
390
|
-
invariants: [
|
|
391
|
-
{
|
|
392
|
-
id: "example-no-console",
|
|
393
|
-
description: "No console.log in production code",
|
|
394
|
-
rule: INVARIANT_TYPES.NEVER,
|
|
395
|
-
scope: "src/**/*.{ts,tsx,js,jsx}",
|
|
396
|
-
pattern: "console\\.log\\(",
|
|
397
|
-
exclude: ["**/*.test.*", "**/*.spec.*"],
|
|
398
|
-
severity: INVARIANT_SEVERITY.WARNING,
|
|
399
|
-
introduced: new Date().toISOString().split("T")[0],
|
|
400
|
-
},
|
|
401
|
-
],
|
|
402
|
-
groups: {
|
|
403
|
-
security: [],
|
|
404
|
-
architecture: [],
|
|
405
|
-
quality: [],
|
|
406
|
-
},
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
module.exports = {
|
|
411
|
-
INVARIANT_TYPES,
|
|
412
|
-
INVARIANT_SEVERITY,
|
|
413
|
-
INVARIANT_SCHEMA,
|
|
414
|
-
LAWBOOK_FILE_SCHEMA,
|
|
415
|
-
createInvariantTemplate,
|
|
416
|
-
validateInvariant,
|
|
417
|
-
parseLawbook,
|
|
418
|
-
serializeLawbook,
|
|
419
|
-
createDefaultLawbook,
|
|
420
|
-
};
|