@vibecheckai/cli 3.1.8 → 3.2.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.
Files changed (36) hide show
  1. package/bin/registry.js +106 -116
  2. package/bin/runners/context/generators/mcp.js +18 -0
  3. package/bin/runners/context/index.js +72 -4
  4. package/bin/runners/context/proof-context.js +293 -1
  5. package/bin/runners/context/security-scanner.js +311 -73
  6. package/bin/runners/lib/analyzers.js +607 -20
  7. package/bin/runners/lib/detectors-v2.js +172 -15
  8. package/bin/runners/lib/entitlements-v2.js +48 -1
  9. package/bin/runners/lib/evidence-pack.js +678 -0
  10. package/bin/runners/lib/html-proof-report.js +913 -0
  11. package/bin/runners/lib/missions/plan.js +231 -41
  12. package/bin/runners/lib/missions/templates.js +125 -0
  13. package/bin/runners/lib/scan-output.js +492 -253
  14. package/bin/runners/lib/ship-output.js +901 -641
  15. package/bin/runners/runCheckpoint.js +44 -3
  16. package/bin/runners/runContext.d.ts +4 -0
  17. package/bin/runners/runDoctor.js +10 -2
  18. package/bin/runners/runFix.js +51 -341
  19. package/bin/runners/runInit.js +11 -0
  20. package/bin/runners/runPolish.d.ts +4 -0
  21. package/bin/runners/runPolish.js +608 -29
  22. package/bin/runners/runProve.js +210 -25
  23. package/bin/runners/runReality.js +846 -101
  24. package/bin/runners/runScan.js +238 -4
  25. package/bin/runners/runShip.js +19 -3
  26. package/bin/runners/runWatch.js +14 -1
  27. package/bin/vibecheck.js +32 -2
  28. package/mcp-server/consolidated-tools.js +408 -42
  29. package/mcp-server/index.js +152 -15
  30. package/mcp-server/proof-tools.js +571 -0
  31. package/mcp-server/tier-auth.js +22 -19
  32. package/mcp-server/tools-v3.js +744 -0
  33. package/mcp-server/truth-firewall-tools.js +190 -4
  34. package/package.json +3 -1
  35. package/bin/runners/runInstall.js +0 -281
  36. package/bin/runners/runLabs.js +0 -341
@@ -3,13 +3,16 @@
3
3
  /**
4
4
  * vibecheck MCP Server v2.0 - Clean Product Surface
5
5
  *
6
- * 6 Public Tools (maps to CLI):
7
- * vibecheck.scan - Find truth
8
- * vibecheck.gate - Enforce truth in CI
9
- * vibecheck.fix - Apply safe patches
10
- * vibecheck.proof - Premium verification (mocks, reality)
11
- * vibecheck.report - Access artifacts
12
- * vibecheck.status - Health and config info
6
+ * Curated Tools for AI Agents:
7
+ * vibecheck.ctx - Build truthpack/context
8
+ * vibecheck.scan - Static scan for issues
9
+ * vibecheck.ship - Verdict with evidence
10
+ * vibecheck.get_truthpack - Ground truth
11
+ * vibecheck.validate_claim - Evidence-based claim validation
12
+ * vibecheck.compile_context - Task-focused context
13
+ * vibecheck.search_evidence - Evidence search
14
+ * vibecheck.find_counterexamples - Falsification
15
+ * vibecheck.check_invariants - Invariant checks
13
16
  *
14
17
  * Everything else is parameters on these tools.
15
18
  */
@@ -84,27 +87,126 @@ import { mdcGeneratorTool, handleMDCGeneration } from "./mdc-generator.js";
84
87
  import { TRUTH_CONTEXT_TOOLS, handleTruthContextTool } from "./truth-context.js";
85
88
 
86
89
  // Import Truth Firewall tools (Hallucination Stopper)
87
- import { TRUTH_FIREWALL_TOOLS, handleTruthFirewallTool } from "./truth-firewall-tools.js";
90
+ import {
91
+ TRUTH_FIREWALL_TOOLS,
92
+ handleTruthFirewallTool,
93
+ hasRecentClaimValidation,
94
+ getContextAttribution,
95
+ } from "./truth-firewall-tools.js";
96
+
97
+ // Context attribution message
98
+ const CONTEXT_ATTRIBUTION = "🧠 Context enhanced by vibecheck";
88
99
 
89
100
  // Import Consolidated Tools (15 focused tools - recommended surface)
90
101
  import { CONSOLIDATED_TOOLS, handleConsolidatedTool } from "./consolidated-tools.js";
91
102
 
103
+ // Import v3 Tools (10 focused tools - STARTER+ only, no free tools)
104
+ import { MCP_TOOLS_V3, handleToolV3, TOOL_TIERS as V3_TOOL_TIERS } from "./tools-v3.js";
105
+
92
106
  // Import tier auth for entitlement checking
93
107
  import { checkFeatureAccess } from "./tier-auth.js";
94
108
 
109
+ /**
110
+ * TRUTH FIREWALL CONFIGURATION
111
+ *
112
+ * Tools that make assertions or change code MUST have recent claim validation.
113
+ * Policy modes: strict (default for agents), balanced, permissive
114
+ */
115
+ const STRICT_GUARDRAIL_TOOLS = new Set([
116
+ "vibecheck.scan",
117
+ "vibecheck.ship",
118
+ "vibecheck.ctx",
119
+ "vibecheck.fix",
120
+ "vibecheck.prove",
121
+ "vibecheck.autopilot_apply",
122
+ ]);
123
+
124
+ // Tools that modify code or make assertions - require truth firewall
125
+ const CODE_CHANGING_TOOLS = new Set([
126
+ "vibecheck.fix",
127
+ "vibecheck.autopilot_apply",
128
+ "vibecheck.propose_patch",
129
+ ]);
130
+
131
+ // Policy thresholds (aligned with proof-context.js EVIDENCE_SCHEMA)
132
+ const POLICY_THRESHOLDS = {
133
+ strict: { minConfidence: 0.8, allowUnknown: false, requireValidation: true },
134
+ balanced: { minConfidence: 0.6, allowUnknown: false, requireValidation: true },
135
+ permissive: { minConfidence: 0.4, allowUnknown: true, requireValidation: false },
136
+ };
137
+
138
+ function getTruthPolicy(args) {
139
+ const policy = args?.policy || "strict";
140
+ return POLICY_THRESHOLDS[policy] ? policy : "strict";
141
+ }
142
+
143
+ function getPolicyConfig(policy) {
144
+ return POLICY_THRESHOLDS[policy] || POLICY_THRESHOLDS.strict;
145
+ }
146
+
147
+ async function emitGuardrailMetric(projectPath, metric) {
148
+ try {
149
+ const auditDir = path.join(projectPath, ".vibecheck", "audit");
150
+ await fs.mkdir(auditDir, { recursive: true });
151
+ const record = JSON.stringify({ ...metric, timestamp: new Date().toISOString() });
152
+ await fs.appendFile(path.join(auditDir, "guardrail-metrics.jsonl"), `${record}\n`);
153
+ } catch {
154
+ // ignore metrics write failures
155
+ }
156
+ }
157
+
158
+ /**
159
+ * Check if a code-changing tool should be blocked due to missing validation.
160
+ * Returns { blocked: boolean, reason?: string, suggestion?: string }
161
+ */
162
+ function checkTruthFirewallBlock(toolName, args, projectPath) {
163
+ const policy = getTruthPolicy(args);
164
+ const policyConfig = getPolicyConfig(policy);
165
+
166
+ // Skip validation check if permissive mode and validation not required
167
+ if (!policyConfig.requireValidation) {
168
+ return { blocked: false };
169
+ }
170
+
171
+ // Check if this is a code-changing tool that requires validation
172
+ if (!CODE_CHANGING_TOOLS.has(toolName) && !STRICT_GUARDRAIL_TOOLS.has(toolName)) {
173
+ return { blocked: false };
174
+ }
175
+
176
+ // Check for recent claim validation
177
+ if (!hasRecentClaimValidation(projectPath)) {
178
+ return {
179
+ blocked: true,
180
+ reason: `Truth firewall requires claim validation before ${toolName}`,
181
+ code: "TRUTH_FIREWALL_REQUIRED",
182
+ suggestion: "Call vibecheck.validate_claim or vibecheck.get_truthpack before proceeding",
183
+ nextSteps: [
184
+ "Call vibecheck.get_truthpack with refresh=true for current evidence",
185
+ "Call vibecheck.validate_claim for critical assumptions",
186
+ `Re-run ${toolName} after validation`,
187
+ ],
188
+ };
189
+ }
190
+
191
+ return { blocked: false };
192
+ }
193
+
95
194
  // ============================================================================
96
195
  // TOOL DEFINITIONS - Public Tools (Clean Product Surface)
97
196
  // ============================================================================
98
197
 
99
- // RECOMMENDED: Use consolidated tools (15 focused, evidence-backed tools)
198
+ // RECOMMENDED: Use v3 tools (10 focused tools, STARTER+ only, no free tools)
100
199
  // These map directly to CLI commands and return file/line citations
200
+ // Set VIBECHECK_MCP_V3=false to use legacy tools
201
+ const USE_V3_TOOLS = process.env.VIBECHECK_MCP_V3 !== 'false';
101
202
  const USE_CONSOLIDATED_TOOLS = process.env.VIBECHECK_MCP_CONSOLIDATED !== 'false';
102
203
 
103
- const TOOLS = USE_CONSOLIDATED_TOOLS ? [
104
- // 15 Consolidated Tools - recommended for new integrations
204
+ const TOOLS = USE_V3_TOOLS ? [
205
+ // v3: 10 focused tools for STARTER+ (no free MCP tools)
206
+ ...MCP_TOOLS_V3,
207
+ ] : USE_CONSOLIDATED_TOOLS ? [
208
+ // Curated tools for agents (legacy)
105
209
  ...CONSOLIDATED_TOOLS,
106
- // Keep Truth Firewall for backward compatibility
107
- ...TRUTH_FIREWALL_TOOLS,
108
210
  ] : [
109
211
  // Legacy: Full tool set (50+ tools) - for backward compatibility
110
212
  // PRIORITY: Truth Firewall tools (Hallucination Stopper) - agents MUST use these
@@ -741,6 +843,38 @@ class VibecheckMCP {
741
843
  emitToolInvoke(name, args, "success", { projectPath });
742
844
 
743
845
  try {
846
+ // TRUTH FIREWALL CHECK - enforce validation before code-changing tools
847
+ const firewallCheck = checkTruthFirewallBlock(name, args, projectPath);
848
+ if (firewallCheck.blocked) {
849
+ const policy = getTruthPolicy(args);
850
+ await emitGuardrailMetric(projectPath, {
851
+ event: "truth_firewall_block",
852
+ tool: name,
853
+ policy,
854
+ reason: firewallCheck.code || "no_recent_claim_validation",
855
+ });
856
+ return this.error(firewallCheck.reason, {
857
+ code: firewallCheck.code,
858
+ suggestion: firewallCheck.suggestion,
859
+ nextSteps: firewallCheck.nextSteps || [],
860
+ });
861
+ }
862
+
863
+ // Handle v3 tools (10 consolidated tools, STARTER+ only)
864
+ if (USE_V3_TOOLS && V3_TOOL_TIERS[name]) {
865
+ // Get user tier from context or args
866
+ const userTier = args?.tier || process.env.VIBECHECK_TIER || 'free';
867
+ const result = await handleToolV3(name, args, { tier: userTier });
868
+
869
+ if (result.error) {
870
+ return this.error(result.error, { tier: result.tier, required: result.required });
871
+ }
872
+
873
+ return {
874
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
875
+ };
876
+ }
877
+
744
878
  // Handle intelligence tools first
745
879
  if (name.startsWith("vibecheck.intelligence.")) {
746
880
  return await handleIntelligenceTool(name, args, __dirname);
@@ -1045,8 +1179,11 @@ class VibecheckMCP {
1045
1179
  }
1046
1180
 
1047
1181
  // Helpers
1048
- success(text) {
1049
- return { content: [{ type: "text", text }] };
1182
+ success(text, includeAttribution = true) {
1183
+ const finalText = includeAttribution
1184
+ ? `${text}\n\n---\n_${CONTEXT_ATTRIBUTION}_`
1185
+ : text;
1186
+ return { content: [{ type: "text", text: finalText }] };
1050
1187
  }
1051
1188
 
1052
1189
  error(text, options = {}) {