@vibecheckai/cli 3.2.5 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/.generated +25 -25
- package/bin/dev/run-v2-torture.js +30 -30
- package/bin/registry.js +192 -5
- package/bin/runners/lib/__tests__/entitlements-v2.test.js +295 -295
- package/bin/runners/lib/agent-firewall/change-packet/builder.js +280 -6
- package/bin/runners/lib/agent-firewall/critic/index.js +151 -0
- package/bin/runners/lib/agent-firewall/critic/judge.js +432 -0
- package/bin/runners/lib/agent-firewall/critic/prompts.js +305 -0
- package/bin/runners/lib/agent-firewall/lawbook/distributor.js +465 -0
- package/bin/runners/lib/agent-firewall/lawbook/evaluator.js +604 -0
- package/bin/runners/lib/agent-firewall/lawbook/index.js +304 -0
- package/bin/runners/lib/agent-firewall/lawbook/registry.js +514 -0
- package/bin/runners/lib/agent-firewall/lawbook/schema.js +420 -0
- package/bin/runners/lib/agent-firewall/logger.js +141 -0
- package/bin/runners/lib/agent-firewall/policy/loader.js +312 -4
- package/bin/runners/lib/agent-firewall/policy/rules/ghost-env.js +113 -1
- package/bin/runners/lib/agent-firewall/policy/rules/ghost-route.js +133 -6
- package/bin/runners/lib/agent-firewall/proposal/extractor.js +394 -0
- package/bin/runners/lib/agent-firewall/proposal/index.js +212 -0
- package/bin/runners/lib/agent-firewall/proposal/schema.js +251 -0
- package/bin/runners/lib/agent-firewall/proposal/validator.js +386 -0
- package/bin/runners/lib/agent-firewall/reality/index.js +332 -0
- package/bin/runners/lib/agent-firewall/reality/state.js +625 -0
- package/bin/runners/lib/agent-firewall/reality/watcher.js +322 -0
- package/bin/runners/lib/agent-firewall/risk/index.js +173 -0
- package/bin/runners/lib/agent-firewall/risk/scorer.js +328 -0
- package/bin/runners/lib/agent-firewall/risk/thresholds.js +321 -0
- package/bin/runners/lib/agent-firewall/risk/vectors.js +421 -0
- package/bin/runners/lib/agent-firewall/simulator/diff-simulator.js +472 -0
- package/bin/runners/lib/agent-firewall/simulator/import-resolver.js +346 -0
- package/bin/runners/lib/agent-firewall/simulator/index.js +181 -0
- package/bin/runners/lib/agent-firewall/simulator/route-validator.js +380 -0
- package/bin/runners/lib/agent-firewall/time-machine/incident-correlator.js +661 -0
- package/bin/runners/lib/agent-firewall/time-machine/index.js +267 -0
- package/bin/runners/lib/agent-firewall/time-machine/replay-engine.js +436 -0
- package/bin/runners/lib/agent-firewall/time-machine/state-reconstructor.js +490 -0
- package/bin/runners/lib/agent-firewall/time-machine/timeline-builder.js +530 -0
- package/bin/runners/lib/analyzers.js +81 -18
- package/bin/runners/lib/api-client.js +269 -0
- package/bin/runners/lib/auth-truth.js +193 -193
- package/bin/runners/lib/authority-badge.js +425 -0
- package/bin/runners/lib/backup.js +62 -62
- package/bin/runners/lib/billing.js +107 -107
- package/bin/runners/lib/claims.js +118 -118
- package/bin/runners/lib/cli-output.js +7 -1
- package/bin/runners/lib/cli-ui.js +540 -540
- package/bin/runners/lib/contracts/auth-contract.js +202 -202
- package/bin/runners/lib/contracts/env-contract.js +181 -181
- package/bin/runners/lib/contracts/external-contract.js +206 -206
- package/bin/runners/lib/contracts/guard.js +168 -168
- package/bin/runners/lib/contracts/index.js +89 -89
- package/bin/runners/lib/contracts/plan-validator.js +311 -311
- package/bin/runners/lib/contracts/route-contract.js +199 -199
- package/bin/runners/lib/contracts.js +804 -804
- package/bin/runners/lib/detect.js +89 -89
- package/bin/runners/lib/doctor/autofix.js +254 -254
- package/bin/runners/lib/doctor/index.js +37 -37
- package/bin/runners/lib/doctor/modules/dependencies.js +325 -325
- package/bin/runners/lib/doctor/modules/index.js +46 -46
- package/bin/runners/lib/doctor/modules/network.js +250 -250
- package/bin/runners/lib/doctor/modules/project.js +312 -312
- package/bin/runners/lib/doctor/modules/runtime.js +224 -224
- package/bin/runners/lib/doctor/modules/security.js +348 -348
- package/bin/runners/lib/doctor/modules/system.js +213 -213
- package/bin/runners/lib/doctor/modules/vibecheck.js +394 -394
- package/bin/runners/lib/doctor/reporter.js +262 -262
- package/bin/runners/lib/doctor/service.js +262 -262
- package/bin/runners/lib/doctor/types.js +113 -113
- package/bin/runners/lib/doctor/ui.js +263 -263
- package/bin/runners/lib/doctor-v2.js +608 -608
- package/bin/runners/lib/drift.js +425 -425
- package/bin/runners/lib/enforcement.js +72 -72
- package/bin/runners/lib/enterprise-detect.js +603 -603
- package/bin/runners/lib/enterprise-init.js +942 -942
- package/bin/runners/lib/env-resolver.js +417 -417
- package/bin/runners/lib/env-template.js +66 -66
- package/bin/runners/lib/env.js +189 -189
- package/bin/runners/lib/error-handler.js +16 -9
- package/bin/runners/lib/exit-codes.js +275 -0
- package/bin/runners/lib/extractors/client-calls.js +990 -990
- package/bin/runners/lib/extractors/fastify-route-dump.js +573 -573
- package/bin/runners/lib/extractors/fastify-routes.js +426 -426
- package/bin/runners/lib/extractors/index.js +363 -363
- package/bin/runners/lib/extractors/next-routes.js +524 -524
- package/bin/runners/lib/extractors/proof-graph.js +431 -431
- package/bin/runners/lib/extractors/route-matcher.js +451 -451
- package/bin/runners/lib/extractors/truthpack-v2.js +377 -377
- package/bin/runners/lib/extractors/ui-bindings.js +547 -547
- package/bin/runners/lib/findings-schema.js +281 -281
- package/bin/runners/lib/firewall-prompt.js +50 -50
- package/bin/runners/lib/global-flags.js +37 -0
- package/bin/runners/lib/graph/graph-builder.js +265 -265
- package/bin/runners/lib/graph/html-renderer.js +413 -413
- package/bin/runners/lib/graph/index.js +32 -32
- package/bin/runners/lib/graph/runtime-collector.js +215 -215
- package/bin/runners/lib/graph/static-extractor.js +518 -518
- package/bin/runners/lib/help-formatter.js +413 -0
- package/bin/runners/lib/html-report.js +650 -650
- package/bin/runners/lib/llm.js +75 -75
- package/bin/runners/lib/logger.js +38 -0
- package/bin/runners/lib/meter.js +61 -61
- package/bin/runners/lib/missions/evidence.js +126 -126
- package/bin/runners/lib/patch.js +40 -40
- package/bin/runners/lib/permissions/auth-model.js +213 -213
- package/bin/runners/lib/permissions/idor-prover.js +205 -205
- package/bin/runners/lib/permissions/index.js +45 -45
- package/bin/runners/lib/permissions/matrix-builder.js +198 -198
- package/bin/runners/lib/pkgjson.js +28 -28
- package/bin/runners/lib/policy.js +295 -295
- package/bin/runners/lib/preflight.js +142 -142
- package/bin/runners/lib/reality/correlation-detectors.js +359 -359
- package/bin/runners/lib/reality/index.js +318 -318
- package/bin/runners/lib/reality/request-hashing.js +416 -416
- package/bin/runners/lib/reality/request-mapper.js +453 -453
- package/bin/runners/lib/reality/safety-rails.js +463 -463
- package/bin/runners/lib/reality/semantic-snapshot.js +408 -408
- package/bin/runners/lib/reality/toast-detector.js +393 -393
- package/bin/runners/lib/reality-findings.js +84 -84
- package/bin/runners/lib/receipts.js +179 -179
- package/bin/runners/lib/redact.js +29 -29
- package/bin/runners/lib/replay/capsule-manager.js +154 -154
- package/bin/runners/lib/replay/index.js +263 -263
- package/bin/runners/lib/replay/player.js +348 -348
- package/bin/runners/lib/replay/recorder.js +331 -331
- package/bin/runners/lib/report.js +135 -135
- package/bin/runners/lib/route-detection.js +1140 -1140
- package/bin/runners/lib/sandbox/index.js +59 -59
- package/bin/runners/lib/sandbox/proof-chain.js +399 -399
- package/bin/runners/lib/sandbox/sandbox-runner.js +205 -205
- package/bin/runners/lib/sandbox/worktree.js +174 -174
- package/bin/runners/lib/schema-validator.js +350 -350
- package/bin/runners/lib/schemas/contracts.schema.json +160 -160
- package/bin/runners/lib/schemas/finding.schema.json +100 -100
- package/bin/runners/lib/schemas/mission-pack.schema.json +206 -206
- package/bin/runners/lib/schemas/proof-graph.schema.json +176 -176
- package/bin/runners/lib/schemas/reality-report.schema.json +162 -162
- package/bin/runners/lib/schemas/share-pack.schema.json +180 -180
- package/bin/runners/lib/schemas/ship-report.schema.json +117 -117
- package/bin/runners/lib/schemas/truthpack-v2.schema.json +303 -303
- package/bin/runners/lib/schemas/validator.js +438 -438
- package/bin/runners/lib/score-history.js +282 -282
- package/bin/runners/lib/share-pack.js +239 -239
- package/bin/runners/lib/snippets.js +67 -67
- package/bin/runners/lib/unified-cli-output.js +604 -0
- package/bin/runners/lib/upsell.js +658 -510
- package/bin/runners/lib/usage.js +153 -153
- package/bin/runners/lib/validate-patch.js +156 -156
- package/bin/runners/lib/verdict-engine.js +628 -628
- package/bin/runners/reality/engine.js +917 -917
- package/bin/runners/reality/flows.js +122 -122
- package/bin/runners/reality/report.js +378 -378
- package/bin/runners/reality/session.js +193 -193
- package/bin/runners/runAgent.d.ts +5 -0
- package/bin/runners/runApprove.js +1200 -0
- package/bin/runners/runAuth.js +324 -95
- package/bin/runners/runCheckpoint.js +39 -21
- package/bin/runners/runClassify.js +859 -0
- package/bin/runners/runContext.js +136 -24
- package/bin/runners/runDoctor.js +108 -68
- package/bin/runners/runFirewall.d.ts +5 -0
- package/bin/runners/runFirewallHook.d.ts +5 -0
- package/bin/runners/runFix.js +6 -5
- package/bin/runners/runGuard.js +262 -168
- package/bin/runners/runInit.js +3 -2
- package/bin/runners/runMcp.js +130 -52
- package/bin/runners/runPolish.js +43 -20
- package/bin/runners/runProve.js +1 -2
- package/bin/runners/runReport.js +3 -2
- package/bin/runners/runScan.js +145 -44
- package/bin/runners/runShip.js +3 -4
- package/bin/runners/runTruth.d.ts +5 -0
- package/bin/runners/runValidate.js +19 -2
- package/bin/runners/runWatch.js +104 -53
- package/bin/vibecheck.js +106 -19
- package/mcp-server/HARDENING_SUMMARY.md +299 -0
- package/mcp-server/agent-firewall-interceptor.js +367 -31
- package/mcp-server/authority-tools.js +569 -0
- package/mcp-server/conductor/conflict-resolver.js +588 -0
- package/mcp-server/conductor/execution-planner.js +544 -0
- package/mcp-server/conductor/index.js +377 -0
- package/mcp-server/conductor/lock-manager.js +615 -0
- package/mcp-server/conductor/request-queue.js +550 -0
- package/mcp-server/conductor/session-manager.js +500 -0
- package/mcp-server/conductor/tools.js +510 -0
- package/mcp-server/index.js +1199 -208
- package/mcp-server/lib/api-client.cjs +305 -0
- package/mcp-server/lib/logger.cjs +30 -0
- package/mcp-server/logger.js +173 -0
- package/mcp-server/package.json +2 -2
- package/mcp-server/premium-tools.js +2 -2
- package/mcp-server/tier-auth.js +351 -136
- package/mcp-server/tools/index.js +72 -72
- package/mcp-server/truth-firewall-tools.js +145 -15
- package/mcp-server/vibecheck-tools.js +2 -2
- package/package.json +2 -3
- package/mcp-server/index.old.js +0 -4137
- package/mcp-server/package-lock.json +0 -165
package/bin/runners/runGuard.js
CHANGED
|
@@ -1,168 +1,262 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vibecheck guard - Unified trust boundary enforcement
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
${
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
${
|
|
83
|
-
${
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
:
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
1
|
+
/**
|
|
2
|
+
* vibecheck guard - Unified trust boundary enforcement
|
|
3
|
+
*
|
|
4
|
+
* ═══════════════════════════════════════════════════════════════════════════════
|
|
5
|
+
* World-Class AI Guardrails
|
|
6
|
+
* ═══════════════════════════════════════════════════════════════════════════════
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const path = require("path");
|
|
10
|
+
const fs = require("fs");
|
|
11
|
+
const { parseGlobalFlags, shouldSuppressOutput, isJsonMode } = require("./lib/global-flags");
|
|
12
|
+
const { EXIT } = require("./lib/exit-codes");
|
|
13
|
+
const {
|
|
14
|
+
ansi,
|
|
15
|
+
sym,
|
|
16
|
+
renderMinimalHeader,
|
|
17
|
+
renderSectionHeader,
|
|
18
|
+
renderVerdict,
|
|
19
|
+
renderSuccess,
|
|
20
|
+
renderError,
|
|
21
|
+
renderWarning,
|
|
22
|
+
renderFooter,
|
|
23
|
+
Spinner,
|
|
24
|
+
getTierFromKey,
|
|
25
|
+
} = require("./lib/unified-cli-output");
|
|
26
|
+
|
|
27
|
+
// Import underlying implementations
|
|
28
|
+
let runValidate, runPromptFirewall;
|
|
29
|
+
try {
|
|
30
|
+
runValidate = require("./runValidate").runValidate;
|
|
31
|
+
} catch {
|
|
32
|
+
runValidate = null;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
runPromptFirewall = require("./runPromptFirewall").runPromptFirewall;
|
|
36
|
+
} catch {
|
|
37
|
+
runPromptFirewall = null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function printHelp() {
|
|
41
|
+
console.log(`
|
|
42
|
+
${ansi.bold}USAGE${ansi.reset}
|
|
43
|
+
${ansi.cyan}vibecheck guard${ansi.reset} [options]
|
|
44
|
+
|
|
45
|
+
${ansi.dim}Aliases: ai-guard, firewall, validate${ansi.reset}
|
|
46
|
+
|
|
47
|
+
Validate AI-generated code and prompts. Detects prompt injection attempts,
|
|
48
|
+
verifies claims against your codebase (hallucination checking), and ensures
|
|
49
|
+
AI outputs meet your standards.
|
|
50
|
+
|
|
51
|
+
${ansi.bold}CHECK MODES${ansi.reset}
|
|
52
|
+
${ansi.cyan}--claims${ansi.reset} Verify AI claims against truthpack
|
|
53
|
+
${ansi.cyan}--prompts${ansi.reset} Check code for prompt injection
|
|
54
|
+
${ansi.cyan}--hallucinations${ansi.reset} Detect AI hallucination patterns
|
|
55
|
+
${ansi.dim}(default: run all checks)${ansi.reset}
|
|
56
|
+
|
|
57
|
+
${ansi.bold}OPTIONS${ansi.reset}
|
|
58
|
+
${ansi.cyan}--file <path>${ansi.reset} Check specific file(s)
|
|
59
|
+
${ansi.cyan}--strict${ansi.reset} Fail on warnings (default: fail on errors only)
|
|
60
|
+
${ansi.cyan}--json${ansi.reset} Output as JSON (CI integration)
|
|
61
|
+
${ansi.cyan}--quiet, -q${ansi.reset} Suppress non-essential output
|
|
62
|
+
${ansi.cyan}--help, -h${ansi.reset} Show this help
|
|
63
|
+
|
|
64
|
+
${ansi.bold}EXAMPLES${ansi.reset}
|
|
65
|
+
${ansi.dim}# Run all guardrail checks${ansi.reset}
|
|
66
|
+
vibecheck guard
|
|
67
|
+
|
|
68
|
+
${ansi.dim}# Verify AI claims in specific file${ansi.reset}
|
|
69
|
+
vibecheck guard --claims --file api.ts
|
|
70
|
+
|
|
71
|
+
${ansi.dim}# Prompt injection scan only${ansi.reset}
|
|
72
|
+
vibecheck guard --prompts
|
|
73
|
+
|
|
74
|
+
${ansi.dim}# CI pipeline (strict, JSON output)${ansi.reset}
|
|
75
|
+
vibecheck guard --strict --json
|
|
76
|
+
|
|
77
|
+
${ansi.bold}EXIT CODES${ansi.reset}
|
|
78
|
+
0 All checks passed
|
|
79
|
+
1 Warnings found (non-blocking)
|
|
80
|
+
2 Errors found (blocking issues)
|
|
81
|
+
|
|
82
|
+
${ansi.dim}────────────────────────────────────────────────────────────────────${ansi.reset}
|
|
83
|
+
${ansi.dim}Documentation: https://docs.vibecheckai.dev/cli/guard${ansi.reset}
|
|
84
|
+
`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async function runGuard(args = []) {
|
|
88
|
+
const { flags: globalFlags } = parseGlobalFlags(args);
|
|
89
|
+
const quiet = shouldSuppressOutput(globalFlags);
|
|
90
|
+
const json = isJsonMode(globalFlags) || args.includes("--json");
|
|
91
|
+
const startTime = Date.now();
|
|
92
|
+
|
|
93
|
+
// Parse arguments
|
|
94
|
+
if (globalFlags.help || args.includes("--help") || args.includes("-h")) {
|
|
95
|
+
printHelp();
|
|
96
|
+
return EXIT.SUCCESS;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const runClaims = args.includes("--claims") || (!args.includes("--prompts") && !args.includes("--hallucinations"));
|
|
100
|
+
const runPrompts = args.includes("--prompts") || (!args.includes("--claims") && !args.includes("--hallucinations"));
|
|
101
|
+
const runHallucinations = args.includes("--hallucinations") || (!args.includes("--claims") && !args.includes("--prompts"));
|
|
102
|
+
const strict = args.includes("--strict");
|
|
103
|
+
|
|
104
|
+
// Validate --file if provided
|
|
105
|
+
const fileIndex = args.indexOf("--file");
|
|
106
|
+
if (fileIndex !== -1) {
|
|
107
|
+
const filePath = args[fileIndex + 1];
|
|
108
|
+
if (!filePath || filePath.startsWith("--")) {
|
|
109
|
+
if (json) {
|
|
110
|
+
console.log(JSON.stringify({ success: false, error: "--file requires a path argument" }));
|
|
111
|
+
} else {
|
|
112
|
+
renderError("--file requires a path argument");
|
|
113
|
+
}
|
|
114
|
+
return EXIT.USER_ERROR;
|
|
115
|
+
}
|
|
116
|
+
if (!fs.existsSync(filePath)) {
|
|
117
|
+
if (json) {
|
|
118
|
+
console.log(JSON.stringify({ success: false, error: `File not found: ${filePath}` }));
|
|
119
|
+
} else {
|
|
120
|
+
renderError(`File not found: ${filePath}`);
|
|
121
|
+
}
|
|
122
|
+
return EXIT.NOT_FOUND;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const results = {
|
|
127
|
+
claims: null,
|
|
128
|
+
prompts: null,
|
|
129
|
+
hallucinations: null,
|
|
130
|
+
verdict: "PASS",
|
|
131
|
+
errors: 0,
|
|
132
|
+
warnings: 0,
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
try {
|
|
136
|
+
if (!quiet && !json) {
|
|
137
|
+
renderMinimalHeader("guard", "starter");
|
|
138
|
+
renderSectionHeader("Trust Boundary Checks", sym.shield);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Run claims verification
|
|
142
|
+
if (runClaims) {
|
|
143
|
+
const spinner = !quiet && !json ? new Spinner("Verifying AI claims against truthpack").start() : null;
|
|
144
|
+
|
|
145
|
+
if (!runValidate) {
|
|
146
|
+
results.claims = { skipped: true, reason: "Validator module not available" };
|
|
147
|
+
spinner?.warn("Claims check skipped: module not available");
|
|
148
|
+
} else {
|
|
149
|
+
try {
|
|
150
|
+
const validateArgs = args.filter(a => !["--claims", "--prompts", "--hallucinations"].includes(a));
|
|
151
|
+
const exitCode = await runValidate(validateArgs);
|
|
152
|
+
results.claims = { exitCode, status: exitCode === 0 ? "pass" : "fail" };
|
|
153
|
+
if (exitCode !== 0) {
|
|
154
|
+
results.errors++;
|
|
155
|
+
results.verdict = "FAIL";
|
|
156
|
+
spinner?.fail("Claim verification failed");
|
|
157
|
+
} else {
|
|
158
|
+
spinner?.succeed("Claims verified");
|
|
159
|
+
}
|
|
160
|
+
} catch (e) {
|
|
161
|
+
results.claims = { error: e.message };
|
|
162
|
+
spinner?.warn(`Claims check failed: ${e.message}`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Run prompt injection detection
|
|
168
|
+
if (runPrompts) {
|
|
169
|
+
const spinner = !quiet && !json ? new Spinner("Scanning for prompt injection vulnerabilities").start() : null;
|
|
170
|
+
|
|
171
|
+
if (!runPromptFirewall) {
|
|
172
|
+
results.prompts = { skipped: true, reason: "Firewall module not available" };
|
|
173
|
+
spinner?.warn("Prompt check skipped: module not available");
|
|
174
|
+
} else {
|
|
175
|
+
try {
|
|
176
|
+
const firewallArgs = args.filter(a => !["--claims", "--prompts", "--hallucinations"].includes(a));
|
|
177
|
+
const exitCode = await runPromptFirewall(firewallArgs);
|
|
178
|
+
results.prompts = { exitCode, status: exitCode === 0 ? "pass" : "fail" };
|
|
179
|
+
if (exitCode !== 0) {
|
|
180
|
+
results.warnings++;
|
|
181
|
+
if (strict) results.verdict = "FAIL";
|
|
182
|
+
spinner?.warn("Prompt injection risks detected");
|
|
183
|
+
} else {
|
|
184
|
+
spinner?.succeed("No prompt injection risks");
|
|
185
|
+
}
|
|
186
|
+
} catch (e) {
|
|
187
|
+
results.prompts = { error: e.message };
|
|
188
|
+
spinner?.warn(`Prompt check failed: ${e.message}`);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Run hallucination detection
|
|
194
|
+
if (runHallucinations) {
|
|
195
|
+
const spinner = !quiet && !json ? new Spinner("Detecting hallucination patterns").start() : null;
|
|
196
|
+
|
|
197
|
+
if (!runValidate) {
|
|
198
|
+
results.hallucinations = { skipped: true, reason: "Validator module not available" };
|
|
199
|
+
spinner?.warn("Hallucination check skipped: module not available");
|
|
200
|
+
} else {
|
|
201
|
+
try {
|
|
202
|
+
const validateArgs = ["--hallucinations", ...args.filter(a => !["--claims", "--prompts", "--hallucinations"].includes(a))];
|
|
203
|
+
const exitCode = await runValidate(validateArgs);
|
|
204
|
+
results.hallucinations = { exitCode, status: exitCode === 0 ? "pass" : "fail" };
|
|
205
|
+
if (exitCode !== 0) {
|
|
206
|
+
results.warnings++;
|
|
207
|
+
if (strict) results.verdict = "FAIL";
|
|
208
|
+
spinner?.warn("Potential hallucinations detected");
|
|
209
|
+
} else {
|
|
210
|
+
spinner?.succeed("No hallucination patterns");
|
|
211
|
+
}
|
|
212
|
+
} catch (e) {
|
|
213
|
+
results.hallucinations = { error: e.message };
|
|
214
|
+
spinner?.warn(`Hallucination check failed: ${e.message}`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Summary
|
|
220
|
+
const duration = Date.now() - startTime;
|
|
221
|
+
|
|
222
|
+
if (!quiet && !json) {
|
|
223
|
+
renderVerdict(results.verdict === "PASS" ? "PASS" : "FAIL", {
|
|
224
|
+
warnings: results.warnings,
|
|
225
|
+
critical: results.errors,
|
|
226
|
+
duration,
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
renderFooter({
|
|
230
|
+
nextSteps: results.verdict === "PASS" ? [
|
|
231
|
+
{ cmd: "vibecheck scan", desc: "run full code analysis" },
|
|
232
|
+
{ cmd: "vibecheck ship", desc: "get ship verdict" },
|
|
233
|
+
] : [
|
|
234
|
+
{ cmd: "vibecheck fix --plan-only", desc: "view fix recommendations" },
|
|
235
|
+
],
|
|
236
|
+
docsUrl: "https://docs.vibecheckai.dev/cli/guard",
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (json) {
|
|
241
|
+
console.log(JSON.stringify({ ...results, duration }, null, 2));
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// Return appropriate exit code
|
|
245
|
+
if (results.verdict === "PASS") {
|
|
246
|
+
return EXIT.SUCCESS;
|
|
247
|
+
} else if (results.errors > 0) {
|
|
248
|
+
return EXIT.BLOCKING;
|
|
249
|
+
} else {
|
|
250
|
+
return EXIT.WARNINGS;
|
|
251
|
+
}
|
|
252
|
+
} catch (error) {
|
|
253
|
+
if (json) {
|
|
254
|
+
console.log(JSON.stringify({ success: false, error: error.message }));
|
|
255
|
+
} else {
|
|
256
|
+
renderError(`Guard check failed: ${error.message}`);
|
|
257
|
+
}
|
|
258
|
+
return EXIT.INTERNAL_ERROR;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
module.exports = { runGuard };
|
package/bin/runners/runInit.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
const fs = require("fs");
|
|
13
13
|
const path = require("path");
|
|
14
14
|
const { parseGlobalFlags, shouldShowBanner } = require("./lib/global-flags");
|
|
15
|
+
const { EXIT } = require("./lib/exit-codes");
|
|
15
16
|
|
|
16
17
|
// Use enhanced wizard if available
|
|
17
18
|
let InitWizard;
|
|
@@ -1747,7 +1748,7 @@ async function runInit(args) {
|
|
|
1747
1748
|
console.log(` ${colors.info}${ICONS.info}${c.reset} Run ${c.cyan}vibecheck init --repair${c.reset} to fix partial state`);
|
|
1748
1749
|
}
|
|
1749
1750
|
if (!opts.dryRun) {
|
|
1750
|
-
return
|
|
1751
|
+
return EXIT.INTERNAL_ERROR; // Exit on error unless dry-run
|
|
1751
1752
|
}
|
|
1752
1753
|
}
|
|
1753
1754
|
}
|
|
@@ -1765,7 +1766,7 @@ async function runInit(args) {
|
|
|
1765
1766
|
}
|
|
1766
1767
|
}
|
|
1767
1768
|
if (!opts.dryRun) {
|
|
1768
|
-
return
|
|
1769
|
+
return EXIT.INTERNAL_ERROR;
|
|
1769
1770
|
}
|
|
1770
1771
|
}
|
|
1771
1772
|
}
|