@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,305 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Critic LLM Prompts
|
|
3
|
-
*
|
|
4
|
-
* Prompt templates for the "savage" critic judge.
|
|
5
|
-
* Philosophy: "If it cannot be proven safe, block it."
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
"use strict";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* System prompt for the critic
|
|
12
|
-
*/
|
|
13
|
-
const CRITIC_SYSTEM_PROMPT = `You are a strict code change critic. Your role is to judge whether proposed changes should be allowed.
|
|
14
|
-
|
|
15
|
-
PHILOSOPHY:
|
|
16
|
-
- If a change cannot be proven safe by the repository state, BLOCK it
|
|
17
|
-
- Assumptions that cannot be verified are violations
|
|
18
|
-
- Vague intent is a violation
|
|
19
|
-
- Missing explanations are suspicious
|
|
20
|
-
- Trust nothing, verify everything
|
|
21
|
-
|
|
22
|
-
You output ONLY valid JSON. No explanations outside the JSON.
|
|
23
|
-
|
|
24
|
-
VERDICT OPTIONS:
|
|
25
|
-
- "ALLOW" - Change is safe and well-documented
|
|
26
|
-
- "BLOCK" - Change has unverified assumptions or risks
|
|
27
|
-
- "REQUIRE_CONFIRMATION" - Change needs human review
|
|
28
|
-
|
|
29
|
-
Be conservative. When in doubt, BLOCK.`;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Prompt template for evaluating a proposal
|
|
33
|
-
*/
|
|
34
|
-
const EVALUATION_PROMPT_TEMPLATE = `Evaluate this proposed code change:
|
|
35
|
-
|
|
36
|
-
## Proposal
|
|
37
|
-
Intent: {{intent}}
|
|
38
|
-
Summary: {{summary}}
|
|
39
|
-
Files touched: {{filesTouched}}
|
|
40
|
-
Operations: {{operationsCount}} ({{operationTypes}})
|
|
41
|
-
Declared confidence: {{confidence}}
|
|
42
|
-
|
|
43
|
-
## Assumptions Declared
|
|
44
|
-
{{assumptions}}
|
|
45
|
-
|
|
46
|
-
## Assumption Validation Results
|
|
47
|
-
{{validationResults}}
|
|
48
|
-
|
|
49
|
-
## Risk Assessment
|
|
50
|
-
Risk Score: {{riskScore}}
|
|
51
|
-
Risk Level: {{riskLevel}}
|
|
52
|
-
Risk Factors:
|
|
53
|
-
{{riskFactors}}
|
|
54
|
-
|
|
55
|
-
## Simulation Results
|
|
56
|
-
Simulation Passed: {{simulationPassed}}
|
|
57
|
-
Errors: {{simulationErrors}}
|
|
58
|
-
Warnings: {{simulationWarnings}}
|
|
59
|
-
|
|
60
|
-
## Reality State Summary
|
|
61
|
-
Total files in repo: {{fileCount}}
|
|
62
|
-
Total routes: {{routeCount}}
|
|
63
|
-
Total env vars: {{envVarCount}}
|
|
64
|
-
Affected domains: {{domains}}
|
|
65
|
-
|
|
66
|
-
---
|
|
67
|
-
|
|
68
|
-
Evaluate and respond with JSON only:
|
|
69
|
-
{
|
|
70
|
-
"verdict": "ALLOW" | "BLOCK" | "REQUIRE_CONFIRMATION",
|
|
71
|
-
"confidence": 0.0 to 1.0,
|
|
72
|
-
"reasoning": ["reason 1", "reason 2", ...],
|
|
73
|
-
"violations": ["violation 1", ...] or [],
|
|
74
|
-
"recommendations": ["recommendation 1", ...] or []
|
|
75
|
-
}`;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Prompt for detecting vague/hand-wavy proposals
|
|
79
|
-
*/
|
|
80
|
-
const VAGUENESS_CHECK_PROMPT = `Analyze this proposal for vagueness:
|
|
81
|
-
|
|
82
|
-
Intent: {{intent}}
|
|
83
|
-
Summary: {{summary}}
|
|
84
|
-
Operation count: {{operationCount}}
|
|
85
|
-
|
|
86
|
-
Rate the specificity on a scale of 1-10 (10 = very specific).
|
|
87
|
-
Identify any vague language.
|
|
88
|
-
|
|
89
|
-
Respond with JSON only:
|
|
90
|
-
{
|
|
91
|
-
"specificityScore": 1-10,
|
|
92
|
-
"vagueTerms": ["term1", "term2"],
|
|
93
|
-
"suggestions": ["be more specific about X", ...]
|
|
94
|
-
}`;
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Prompt for assumption verification
|
|
98
|
-
*/
|
|
99
|
-
const ASSUMPTION_VERIFICATION_PROMPT = `Verify these assumptions against the repository state:
|
|
100
|
-
|
|
101
|
-
{{assumptions}}
|
|
102
|
-
|
|
103
|
-
Repository State:
|
|
104
|
-
- Declared env vars: {{declaredEnvVars}}
|
|
105
|
-
- Registered routes: {{registeredRoutes}}
|
|
106
|
-
- Registered services: {{registeredServices}}
|
|
107
|
-
|
|
108
|
-
For each assumption, determine:
|
|
109
|
-
1. Can it be verified from the repo state?
|
|
110
|
-
2. Is there evidence supporting it?
|
|
111
|
-
3. Is it a valid assumption?
|
|
112
|
-
|
|
113
|
-
Respond with JSON only:
|
|
114
|
-
{
|
|
115
|
-
"results": [
|
|
116
|
-
{
|
|
117
|
-
"assumption": "...",
|
|
118
|
-
"verified": true/false,
|
|
119
|
-
"evidence": "..." or null,
|
|
120
|
-
"reason": "..."
|
|
121
|
-
}
|
|
122
|
-
],
|
|
123
|
-
"overallVerificationRate": 0.0 to 1.0
|
|
124
|
-
}`;
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Build evaluation prompt from data
|
|
128
|
-
* @param {Object} data - Prompt data
|
|
129
|
-
* @returns {string} Filled prompt
|
|
130
|
-
*/
|
|
131
|
-
function buildEvaluationPrompt(data) {
|
|
132
|
-
const {
|
|
133
|
-
proposal,
|
|
134
|
-
validationResults,
|
|
135
|
-
riskScore,
|
|
136
|
-
simulationResult,
|
|
137
|
-
realityState,
|
|
138
|
-
} = data;
|
|
139
|
-
|
|
140
|
-
let prompt = EVALUATION_PROMPT_TEMPLATE;
|
|
141
|
-
|
|
142
|
-
// Fill in proposal data
|
|
143
|
-
prompt = prompt.replace("{{intent}}", proposal.intent || "not specified");
|
|
144
|
-
prompt = prompt.replace("{{summary}}", proposal.summary || "not provided");
|
|
145
|
-
prompt = prompt.replace("{{filesTouched}}", (proposal.filesTouched || []).join(", ") || "none");
|
|
146
|
-
prompt = prompt.replace("{{operationsCount}}", String((proposal.operations || []).length));
|
|
147
|
-
prompt = prompt.replace("{{operationTypes}}",
|
|
148
|
-
[...new Set((proposal.operations || []).map(o => o.type))].join(", ") || "none"
|
|
149
|
-
);
|
|
150
|
-
prompt = prompt.replace("{{confidence}}", String(proposal.confidence ?? "not specified"));
|
|
151
|
-
|
|
152
|
-
// Fill in assumptions
|
|
153
|
-
const assumptionsText = (proposal.assumptions || []).length > 0
|
|
154
|
-
? proposal.assumptions.map(a =>
|
|
155
|
-
`- [${a.type}] ${a.key || a.path}: ${a.reason || "no reason given"}`
|
|
156
|
-
).join("\n")
|
|
157
|
-
: "None declared";
|
|
158
|
-
prompt = prompt.replace("{{assumptions}}", assumptionsText);
|
|
159
|
-
|
|
160
|
-
// Fill in validation results
|
|
161
|
-
const validationText = validationResults
|
|
162
|
-
? Object.entries(validationResults).map(([key, val]) =>
|
|
163
|
-
`- ${key}: ${JSON.stringify(val)}`
|
|
164
|
-
).join("\n")
|
|
165
|
-
: "Not available";
|
|
166
|
-
prompt = prompt.replace("{{validationResults}}", validationText);
|
|
167
|
-
|
|
168
|
-
// Fill in risk assessment
|
|
169
|
-
prompt = prompt.replace("{{riskScore}}", String(riskScore?.total ?? "N/A"));
|
|
170
|
-
prompt = prompt.replace("{{riskLevel}}", riskScore?.level || "N/A");
|
|
171
|
-
prompt = prompt.replace("{{riskFactors}}",
|
|
172
|
-
(riskScore?.reasons || []).map(r => `- ${r}`).join("\n") || "None"
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
// Fill in simulation results
|
|
176
|
-
prompt = prompt.replace("{{simulationPassed}}",
|
|
177
|
-
simulationResult ? String(simulationResult.passed) : "Not run"
|
|
178
|
-
);
|
|
179
|
-
prompt = prompt.replace("{{simulationErrors}}",
|
|
180
|
-
simulationResult?.errors?.length > 0
|
|
181
|
-
? simulationResult.errors.map(e => `- ${e.message}`).join("\n")
|
|
182
|
-
: "None"
|
|
183
|
-
);
|
|
184
|
-
prompt = prompt.replace("{{simulationWarnings}}",
|
|
185
|
-
simulationResult?.warnings?.length > 0
|
|
186
|
-
? simulationResult.warnings.map(w => `- ${w.message}`).join("\n")
|
|
187
|
-
: "None"
|
|
188
|
-
);
|
|
189
|
-
|
|
190
|
-
// Fill in reality state
|
|
191
|
-
prompt = prompt.replace("{{fileCount}}", String(realityState?.files?.size ?? "N/A"));
|
|
192
|
-
prompt = prompt.replace("{{routeCount}}", String(realityState?.routes?.length ?? "N/A"));
|
|
193
|
-
prompt = prompt.replace("{{envVarCount}}", String(realityState?.envVars?.size ?? "N/A"));
|
|
194
|
-
prompt = prompt.replace("{{domains}}",
|
|
195
|
-
[...new Set((proposal.operations || []).map(o => classifyDomain(o.path)))].join(", ") || "general"
|
|
196
|
-
);
|
|
197
|
-
|
|
198
|
-
return prompt;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Simple domain classifier (for prompt building)
|
|
203
|
-
*/
|
|
204
|
-
function classifyDomain(filePath) {
|
|
205
|
-
if (!filePath) return "general";
|
|
206
|
-
const s = filePath.toLowerCase();
|
|
207
|
-
if (s.includes("auth")) return "auth";
|
|
208
|
-
if (s.includes("payment") || s.includes("stripe")) return "payments";
|
|
209
|
-
if (s.includes("route") || s.includes("api")) return "routes";
|
|
210
|
-
if (s.includes("db") || s.includes("prisma")) return "database";
|
|
211
|
-
return "general";
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Build vagueness check prompt
|
|
216
|
-
* @param {Object} proposal - Proposal to check
|
|
217
|
-
* @returns {string} Filled prompt
|
|
218
|
-
*/
|
|
219
|
-
function buildVaguenessPrompt(proposal) {
|
|
220
|
-
let prompt = VAGUENESS_CHECK_PROMPT;
|
|
221
|
-
|
|
222
|
-
prompt = prompt.replace("{{intent}}", proposal.intent || "not specified");
|
|
223
|
-
prompt = prompt.replace("{{summary}}", proposal.summary || "not provided");
|
|
224
|
-
prompt = prompt.replace("{{operationCount}}", String((proposal.operations || []).length));
|
|
225
|
-
|
|
226
|
-
return prompt;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Build assumption verification prompt
|
|
231
|
-
* @param {Array} assumptions - Assumptions to verify
|
|
232
|
-
* @param {Object} realityState - Repository state
|
|
233
|
-
* @returns {string} Filled prompt
|
|
234
|
-
*/
|
|
235
|
-
function buildVerificationPrompt(assumptions, realityState) {
|
|
236
|
-
let prompt = ASSUMPTION_VERIFICATION_PROMPT;
|
|
237
|
-
|
|
238
|
-
const assumptionsText = assumptions.map(a =>
|
|
239
|
-
`- [${a.type}] ${a.key || a.path}: ${a.reason || "no reason"}`
|
|
240
|
-
).join("\n");
|
|
241
|
-
|
|
242
|
-
prompt = prompt.replace("{{assumptions}}", assumptionsText);
|
|
243
|
-
|
|
244
|
-
// Extract state summaries
|
|
245
|
-
const declaredEnvVars = realityState?.envVars
|
|
246
|
-
? [...realityState.envVars.keys()].slice(0, 20).join(", ")
|
|
247
|
-
: "not available";
|
|
248
|
-
|
|
249
|
-
const registeredRoutes = realityState?.routes
|
|
250
|
-
? realityState.routes.slice(0, 10).map(r => `${r.method} ${r.path}`).join(", ")
|
|
251
|
-
: "not available";
|
|
252
|
-
|
|
253
|
-
const registeredServices = realityState?.services
|
|
254
|
-
? realityState.services.slice(0, 10).map(s => s.name).join(", ")
|
|
255
|
-
: "not available";
|
|
256
|
-
|
|
257
|
-
prompt = prompt.replace("{{declaredEnvVars}}", declaredEnvVars);
|
|
258
|
-
prompt = prompt.replace("{{registeredRoutes}}", registeredRoutes);
|
|
259
|
-
prompt = prompt.replace("{{registeredServices}}", registeredServices);
|
|
260
|
-
|
|
261
|
-
return prompt;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* Parse critic response
|
|
266
|
-
* @param {string} response - LLM response text
|
|
267
|
-
* @returns {Object} Parsed response
|
|
268
|
-
*/
|
|
269
|
-
function parseCriticResponse(response) {
|
|
270
|
-
try {
|
|
271
|
-
// Try to extract JSON from response
|
|
272
|
-
const jsonMatch = response.match(/\{[\s\S]*\}/);
|
|
273
|
-
if (jsonMatch) {
|
|
274
|
-
return JSON.parse(jsonMatch[0]);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
// If no JSON found, return a default blocked response
|
|
278
|
-
return {
|
|
279
|
-
verdict: "BLOCK",
|
|
280
|
-
confidence: 0.5,
|
|
281
|
-
reasoning: ["Failed to parse critic response"],
|
|
282
|
-
violations: ["Invalid response format"],
|
|
283
|
-
recommendations: [],
|
|
284
|
-
};
|
|
285
|
-
} catch (error) {
|
|
286
|
-
return {
|
|
287
|
-
verdict: "BLOCK",
|
|
288
|
-
confidence: 0.5,
|
|
289
|
-
reasoning: ["Failed to parse critic response: " + error.message],
|
|
290
|
-
violations: ["Invalid JSON in response"],
|
|
291
|
-
recommendations: [],
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
module.exports = {
|
|
297
|
-
CRITIC_SYSTEM_PROMPT,
|
|
298
|
-
EVALUATION_PROMPT_TEMPLATE,
|
|
299
|
-
VAGUENESS_CHECK_PROMPT,
|
|
300
|
-
ASSUMPTION_VERIFICATION_PROMPT,
|
|
301
|
-
buildEvaluationPrompt,
|
|
302
|
-
buildVaguenessPrompt,
|
|
303
|
-
buildVerificationPrompt,
|
|
304
|
-
parseCriticResponse,
|
|
305
|
-
};
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auth Evidence Resolver
|
|
3
|
-
*
|
|
4
|
-
* Resolves auth claims against truthpack.auth.json
|
|
5
|
-
* Checks for auth drift (claimed restriction not enforced).
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
"use strict";
|
|
9
|
-
|
|
10
|
-
const { getAuthRules } = require("../truthpack");
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Resolve auth claim evidence
|
|
14
|
-
* @param {string} projectRoot - Project root directory
|
|
15
|
-
* @param {object} claim - Auth claim
|
|
16
|
-
* @returns {object} Evidence result
|
|
17
|
-
*/
|
|
18
|
-
function resolve(projectRoot, claim) {
|
|
19
|
-
const authData = getAuthRules(projectRoot);
|
|
20
|
-
|
|
21
|
-
// Extract auth keywords from claim value
|
|
22
|
-
const claimText = claim.value.toLowerCase();
|
|
23
|
-
const hasAuthKeywords = /\b(admin|owner|staff|role|scope|permission|auth|authorize|rbac)\b/i.test(claimText);
|
|
24
|
-
|
|
25
|
-
if (!hasAuthKeywords) {
|
|
26
|
-
// Not an auth-related claim
|
|
27
|
-
return {
|
|
28
|
-
result: "PROVEN",
|
|
29
|
-
sources: [],
|
|
30
|
-
reason: "No auth keywords detected in claim"
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Check if auth middleware exists
|
|
35
|
-
const nextMiddleware = authData.nextMiddleware || [];
|
|
36
|
-
const fastifyHooks = authData.fastify?.hooks || [];
|
|
37
|
-
|
|
38
|
-
if (nextMiddleware.length > 0 || fastifyHooks.length > 0) {
|
|
39
|
-
// Auth infrastructure exists
|
|
40
|
-
// Check if claim matches protected patterns
|
|
41
|
-
const matcherPatterns = authData.nextMatcherPatterns || [];
|
|
42
|
-
const claimFile = claim.file || "";
|
|
43
|
-
|
|
44
|
-
// Check if file is in protected path
|
|
45
|
-
const isProtected = matcherPatterns.some(pattern => {
|
|
46
|
-
// Simple pattern matching
|
|
47
|
-
if (pattern.includes("*")) {
|
|
48
|
-
const regex = new RegExp(pattern.replace(/\*/g, ".*"));
|
|
49
|
-
return regex.test(claimFile);
|
|
50
|
-
}
|
|
51
|
-
return claimFile.includes(pattern);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
if (isProtected) {
|
|
55
|
-
return {
|
|
56
|
-
result: "PROVEN",
|
|
57
|
-
sources: [{
|
|
58
|
-
type: "truthpack.auth",
|
|
59
|
-
pointer: claim.pointer,
|
|
60
|
-
confidence: 0.8
|
|
61
|
-
}],
|
|
62
|
-
reason: "Auth claim matches protected route pattern"
|
|
63
|
-
};
|
|
64
|
-
} else {
|
|
65
|
-
// Auth keywords present but route not protected - potential drift
|
|
66
|
-
return {
|
|
67
|
-
result: "CONTRADICTS",
|
|
68
|
-
sources: [{
|
|
69
|
-
type: "truthpack.auth",
|
|
70
|
-
pointer: claim.pointer,
|
|
71
|
-
confidence: 0.7
|
|
72
|
-
}],
|
|
73
|
-
reason: "Auth keywords present but route not in protected patterns (auth drift)"
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
} else {
|
|
77
|
-
// No auth infrastructure - cannot verify
|
|
78
|
-
return {
|
|
79
|
-
result: "UNPROVEN",
|
|
80
|
-
sources: [],
|
|
81
|
-
reason: "No auth middleware found in truthpack"
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
module.exports = {
|
|
87
|
-
resolve
|
|
88
|
-
};
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Contract Evidence Resolver
|
|
3
|
-
*
|
|
4
|
-
* Resolves contract claims against truthpack.contracts.json
|
|
5
|
-
* Checks for contract drift (API shape mismatch).
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
"use strict";
|
|
9
|
-
|
|
10
|
-
const { getContracts } = require("../truthpack");
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Resolve contract claim evidence
|
|
14
|
-
* @param {string} projectRoot - Project root directory
|
|
15
|
-
* @param {object} claim - Contract claim
|
|
16
|
-
* @returns {object} Evidence result
|
|
17
|
-
*/
|
|
18
|
-
function resolve(projectRoot, claim) {
|
|
19
|
-
const contracts = getContracts(projectRoot);
|
|
20
|
-
|
|
21
|
-
// Extract contract identifier from claim
|
|
22
|
-
// Contract claims might reference API endpoints, types, or schemas
|
|
23
|
-
const claimValue = claim.value.toLowerCase();
|
|
24
|
-
|
|
25
|
-
// Check if contracts exist
|
|
26
|
-
if (!contracts || Object.keys(contracts).length === 0) {
|
|
27
|
-
return {
|
|
28
|
-
result: "UNPROVEN",
|
|
29
|
-
sources: [],
|
|
30
|
-
reason: "No contracts found in truthpack"
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Try to match claim against contract definitions
|
|
35
|
-
// This is a simplified check - full implementation would parse contract schemas
|
|
36
|
-
const contractKeys = Object.keys(contracts);
|
|
37
|
-
const matchingContract = contractKeys.find(key =>
|
|
38
|
-
key.toLowerCase().includes(claimValue) ||
|
|
39
|
-
claimValue.includes(key.toLowerCase())
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
if (matchingContract) {
|
|
43
|
-
return {
|
|
44
|
-
result: "PROVEN",
|
|
45
|
-
sources: [{
|
|
46
|
-
type: "truthpack.contracts",
|
|
47
|
-
pointer: claim.pointer,
|
|
48
|
-
confidence: 0.8
|
|
49
|
-
}],
|
|
50
|
-
reason: `Contract ${matchingContract} found in truthpack`
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Check for contract drift by examining the claim context
|
|
55
|
-
// If claim references an API endpoint, check if contract exists for that endpoint
|
|
56
|
-
if (claimValue.includes("api") || claimValue.includes("endpoint")) {
|
|
57
|
-
// Potential contract drift - endpoint referenced but contract not found
|
|
58
|
-
return {
|
|
59
|
-
result: "CONTRADICTS",
|
|
60
|
-
sources: [],
|
|
61
|
-
reason: "API endpoint referenced but contract not found in truthpack (contract drift)"
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Cannot verify contract
|
|
66
|
-
return {
|
|
67
|
-
result: "UNPROVEN",
|
|
68
|
-
sources: [],
|
|
69
|
-
reason: "Contract not found in truthpack"
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
module.exports = {
|
|
74
|
-
resolve
|
|
75
|
-
};
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Environment Variable Evidence Resolver
|
|
3
|
-
*
|
|
4
|
-
* Resolves env var claims against truthpack.env.json
|
|
5
|
-
* Checks for ghost env vars (used but not declared).
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
"use strict";
|
|
9
|
-
|
|
10
|
-
const fs = require("fs");
|
|
11
|
-
const path = require("path");
|
|
12
|
-
const { getEnvVars } = require("../truthpack");
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Resolve env var claim evidence
|
|
16
|
-
* @param {string} projectRoot - Project root directory
|
|
17
|
-
* @param {object} claim - Env var claim
|
|
18
|
-
* @returns {object} Evidence result
|
|
19
|
-
*/
|
|
20
|
-
function resolve(projectRoot, claim) {
|
|
21
|
-
const envData = getEnvVars(projectRoot);
|
|
22
|
-
|
|
23
|
-
// Check declared env vars
|
|
24
|
-
const declared = envData.declared || [];
|
|
25
|
-
const declaredSet = new Set(declared.map(v => v.name || v));
|
|
26
|
-
|
|
27
|
-
// Check declared sources (env.schema.ts, .env.example, etc.)
|
|
28
|
-
const declaredSources = envData.declaredSources || [];
|
|
29
|
-
|
|
30
|
-
const envVarName = claim.value;
|
|
31
|
-
|
|
32
|
-
// Check if env var is declared
|
|
33
|
-
if (declaredSet.has(envVarName)) {
|
|
34
|
-
// Find source file
|
|
35
|
-
const source = declaredSources.find(s =>
|
|
36
|
-
s.vars && s.vars.includes(envVarName)
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
return {
|
|
40
|
-
result: "PROVEN",
|
|
41
|
-
sources: [{
|
|
42
|
-
type: "truthpack.env",
|
|
43
|
-
pointer: source ? source.file : claim.pointer,
|
|
44
|
-
confidence: 0.9
|
|
45
|
-
}],
|
|
46
|
-
reason: `Environment variable ${envVarName} found in truthpack`
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Check if env var exists in .env.example or schema files
|
|
51
|
-
// Check multiple possible locations for .env.example
|
|
52
|
-
const envExamplePaths = [
|
|
53
|
-
path.join(projectRoot, ".env.example"),
|
|
54
|
-
path.join(projectRoot, "apps", "web-ui", ".env.example"),
|
|
55
|
-
path.join(projectRoot, "apps", "api", ".env.example")
|
|
56
|
-
];
|
|
57
|
-
|
|
58
|
-
for (const envExamplePath of envExamplePaths) {
|
|
59
|
-
if (fs.existsSync(envExamplePath)) {
|
|
60
|
-
const envExample = fs.readFileSync(envExamplePath, "utf8");
|
|
61
|
-
if (envExample.includes(envVarName)) {
|
|
62
|
-
const relativePath = path.relative(projectRoot, envExamplePath).replace(/\\/g, "/");
|
|
63
|
-
return {
|
|
64
|
-
result: "PROVEN",
|
|
65
|
-
sources: [{
|
|
66
|
-
type: "repo.search",
|
|
67
|
-
pointer: relativePath,
|
|
68
|
-
confidence: 0.7
|
|
69
|
-
}],
|
|
70
|
-
reason: `Environment variable ${envVarName} found in ${relativePath}`
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const envSchemaPath = findEnvSchemaFile(projectRoot);
|
|
77
|
-
|
|
78
|
-
if (envSchemaPath && fs.existsSync(envSchemaPath)) {
|
|
79
|
-
const envSchema = fs.readFileSync(envSchemaPath, "utf8");
|
|
80
|
-
if (envSchema.includes(envVarName)) {
|
|
81
|
-
return {
|
|
82
|
-
result: "PROVEN",
|
|
83
|
-
sources: [{
|
|
84
|
-
type: "repo.search",
|
|
85
|
-
pointer: envSchemaPath,
|
|
86
|
-
confidence: 0.8
|
|
87
|
-
}],
|
|
88
|
-
reason: `Environment variable ${envVarName} found in env schema`
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// Not found - ghost env var
|
|
94
|
-
return {
|
|
95
|
-
result: "UNPROVEN",
|
|
96
|
-
sources: [],
|
|
97
|
-
reason: `Environment variable ${envVarName} not declared (ghost env var)`
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Find env schema file (env.schema.ts, env.ts, etc.)
|
|
103
|
-
* @param {string} projectRoot - Project root directory
|
|
104
|
-
* @returns {string|null} Path to schema file or null
|
|
105
|
-
*/
|
|
106
|
-
function findEnvSchemaFile(projectRoot) {
|
|
107
|
-
const candidates = [
|
|
108
|
-
"apps/api/src/config/env.schema.ts",
|
|
109
|
-
"apps/api/src/env.schema.ts",
|
|
110
|
-
"src/config/env.schema.ts",
|
|
111
|
-
"src/env.schema.ts",
|
|
112
|
-
"env.schema.ts"
|
|
113
|
-
];
|
|
114
|
-
|
|
115
|
-
for (const candidate of candidates) {
|
|
116
|
-
const fullPath = path.join(projectRoot, candidate);
|
|
117
|
-
if (fs.existsSync(fullPath)) {
|
|
118
|
-
return candidate;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return null;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
module.exports = {
|
|
126
|
-
resolve
|
|
127
|
-
};
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Evidence Resolver
|
|
3
|
-
*
|
|
4
|
-
* Main orchestrator for resolving claims against truthpack.
|
|
5
|
-
* Returns PROVEN, UNPROVEN, or CONTRADICTS for each claim.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
"use strict";
|
|
9
|
-
|
|
10
|
-
const routeEvidence = require("./route-evidence");
|
|
11
|
-
const envEvidence = require("./env-evidence");
|
|
12
|
-
const authEvidence = require("./auth-evidence");
|
|
13
|
-
const contractEvidence = require("./contract-evidence");
|
|
14
|
-
const sideEffectEvidence = require("./side-effect-evidence");
|
|
15
|
-
const { CLAIM_TYPES } = require("../claims/claim-types");
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Resolve evidence for all claims
|
|
19
|
-
* @param {string} projectRoot - Project root directory
|
|
20
|
-
* @param {array} claims - Array of claims to resolve
|
|
21
|
-
* @returns {array} Array of evidence results
|
|
22
|
-
*/
|
|
23
|
-
function resolveEvidence(projectRoot, claims) {
|
|
24
|
-
const results = [];
|
|
25
|
-
|
|
26
|
-
for (let i = 0; i < claims.length; i++) {
|
|
27
|
-
const claim = claims[i];
|
|
28
|
-
const claimId = `claim_${i}`;
|
|
29
|
-
|
|
30
|
-
let result;
|
|
31
|
-
|
|
32
|
-
switch (claim.type) {
|
|
33
|
-
case CLAIM_TYPES.ROUTE:
|
|
34
|
-
result = routeEvidence.resolve(projectRoot, claim);
|
|
35
|
-
break;
|
|
36
|
-
|
|
37
|
-
case CLAIM_TYPES.ENV:
|
|
38
|
-
result = envEvidence.resolve(projectRoot, claim);
|
|
39
|
-
break;
|
|
40
|
-
|
|
41
|
-
case CLAIM_TYPES.AUTH:
|
|
42
|
-
result = authEvidence.resolve(projectRoot, claim);
|
|
43
|
-
break;
|
|
44
|
-
|
|
45
|
-
case CLAIM_TYPES.CONTRACT:
|
|
46
|
-
result = contractEvidence.resolve(projectRoot, claim);
|
|
47
|
-
break;
|
|
48
|
-
|
|
49
|
-
case CLAIM_TYPES.SIDE_EFFECT:
|
|
50
|
-
result = sideEffectEvidence.resolve(projectRoot, claim);
|
|
51
|
-
break;
|
|
52
|
-
|
|
53
|
-
case CLAIM_TYPES.HTTP_CALL:
|
|
54
|
-
// HTTP calls are checked as routes
|
|
55
|
-
result = routeEvidence.resolve(projectRoot, {
|
|
56
|
-
...claim,
|
|
57
|
-
type: CLAIM_TYPES.ROUTE,
|
|
58
|
-
value: extractRouteFromHttpCall(claim.value)
|
|
59
|
-
});
|
|
60
|
-
break;
|
|
61
|
-
|
|
62
|
-
case CLAIM_TYPES.UI_SUCCESS:
|
|
63
|
-
// UI success claims are checked for side effects
|
|
64
|
-
result = sideEffectEvidence.resolve(projectRoot, claim);
|
|
65
|
-
break;
|
|
66
|
-
|
|
67
|
-
default:
|
|
68
|
-
result = {
|
|
69
|
-
claimId,
|
|
70
|
-
result: "UNPROVEN",
|
|
71
|
-
sources: [],
|
|
72
|
-
reason: `Unknown claim type: ${claim.type}`
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
results.push({
|
|
77
|
-
claimId,
|
|
78
|
-
...result
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return results;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Extract route path from HTTP call claim value
|
|
87
|
-
* @param {string} httpCall - HTTP call string (e.g., "GET /api/users")
|
|
88
|
-
* @returns {string} Route path
|
|
89
|
-
*/
|
|
90
|
-
function extractRouteFromHttpCall(httpCall) {
|
|
91
|
-
// Handle "GET /api/users" format
|
|
92
|
-
const match = httpCall.match(/\s+(.+)$/);
|
|
93
|
-
if (match) {
|
|
94
|
-
return match[1];
|
|
95
|
-
}
|
|
96
|
-
// Handle "/api/users" format
|
|
97
|
-
return httpCall.startsWith("/") ? httpCall : `/${httpCall}`;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
module.exports = {
|
|
101
|
-
resolveEvidence
|
|
102
|
-
};
|