@vibecheckai/cli 3.0.3 → 3.0.5

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 (119) hide show
  1. package/bin/cli-hygiene.js +241 -0
  2. package/bin/dev/run-v2-torture.js +30 -0
  3. package/bin/guardrail.js +843 -0
  4. package/bin/runners/cli-utils.js +1070 -0
  5. package/bin/runners/context/ai-task-decomposer.js +337 -0
  6. package/bin/runners/context/analyzer.js +462 -0
  7. package/bin/runners/context/api-contracts.js +427 -0
  8. package/bin/runners/context/context-diff.js +342 -0
  9. package/bin/runners/context/context-pruner.js +291 -0
  10. package/bin/runners/context/dependency-graph.js +414 -0
  11. package/bin/runners/context/generators/claude.js +107 -0
  12. package/bin/runners/context/generators/codex.js +108 -0
  13. package/bin/runners/context/generators/copilot.js +119 -0
  14. package/bin/runners/context/generators/cursor.js +514 -0
  15. package/bin/runners/context/generators/mcp.js +151 -0
  16. package/bin/runners/context/generators/windsurf.js +180 -0
  17. package/bin/runners/context/git-context.js +302 -0
  18. package/bin/runners/context/index.js +1042 -0
  19. package/bin/runners/context/insights.js +173 -0
  20. package/bin/runners/context/mcp-server/generate-rules.js +337 -0
  21. package/bin/runners/context/mcp-server/index.js +1176 -0
  22. package/bin/runners/context/mcp-server/package.json +24 -0
  23. package/bin/runners/context/memory.js +200 -0
  24. package/bin/runners/context/monorepo.js +215 -0
  25. package/bin/runners/context/multi-repo-federation.js +404 -0
  26. package/bin/runners/context/patterns.js +253 -0
  27. package/bin/runners/context/proof-context.js +972 -0
  28. package/bin/runners/context/security-scanner.js +303 -0
  29. package/bin/runners/context/semantic-search.js +350 -0
  30. package/bin/runners/context/shared.js +264 -0
  31. package/bin/runners/context/team-conventions.js +310 -0
  32. package/bin/runners/lib/ai-bridge.js +416 -0
  33. package/bin/runners/lib/analysis-core.js +271 -0
  34. package/bin/runners/lib/analyzers.js +579 -0
  35. package/bin/runners/lib/assets/vibecheck-logo.png +0 -0
  36. package/bin/runners/lib/audit-bridge.js +391 -0
  37. package/bin/runners/lib/auth-truth.js +193 -0
  38. package/bin/runners/lib/auth.js +215 -0
  39. package/bin/runners/lib/backup.js +62 -0
  40. package/bin/runners/lib/billing.js +107 -0
  41. package/bin/runners/lib/claims.js +118 -0
  42. package/bin/runners/lib/cli-ui.js +540 -0
  43. package/bin/runners/lib/compliance-bridge-new.js +0 -0
  44. package/bin/runners/lib/compliance-bridge.js +165 -0
  45. package/bin/runners/lib/contracts/auth-contract.js +202 -0
  46. package/bin/runners/lib/contracts/env-contract.js +181 -0
  47. package/bin/runners/lib/contracts/external-contract.js +206 -0
  48. package/bin/runners/lib/contracts/guard.js +168 -0
  49. package/bin/runners/lib/contracts/index.js +89 -0
  50. package/bin/runners/lib/contracts/plan-validator.js +311 -0
  51. package/bin/runners/lib/contracts/route-contract.js +199 -0
  52. package/bin/runners/lib/contracts.js +804 -0
  53. package/bin/runners/lib/detect.js +89 -0
  54. package/bin/runners/lib/detectors-v2.js +703 -0
  55. package/bin/runners/lib/doctor/autofix.js +254 -0
  56. package/bin/runners/lib/doctor/index.js +37 -0
  57. package/bin/runners/lib/doctor/modules/dependencies.js +325 -0
  58. package/bin/runners/lib/doctor/modules/index.js +46 -0
  59. package/bin/runners/lib/doctor/modules/network.js +250 -0
  60. package/bin/runners/lib/doctor/modules/project.js +312 -0
  61. package/bin/runners/lib/doctor/modules/runtime.js +224 -0
  62. package/bin/runners/lib/doctor/modules/security.js +348 -0
  63. package/bin/runners/lib/doctor/modules/system.js +213 -0
  64. package/bin/runners/lib/doctor/modules/vibecheck.js +394 -0
  65. package/bin/runners/lib/doctor/reporter.js +262 -0
  66. package/bin/runners/lib/doctor/service.js +262 -0
  67. package/bin/runners/lib/doctor/types.js +113 -0
  68. package/bin/runners/lib/doctor/ui.js +263 -0
  69. package/bin/runners/lib/doctor-enhanced.js +233 -0
  70. package/bin/runners/lib/doctor-v2.js +608 -0
  71. package/bin/runners/lib/drift.js +425 -0
  72. package/bin/runners/lib/enforcement.js +72 -0
  73. package/bin/runners/lib/entitlements.js +8 -3
  74. package/bin/runners/lib/env-resolver.js +417 -0
  75. package/bin/runners/lib/extractors/client-calls.js +990 -0
  76. package/bin/runners/lib/extractors/fastify-route-dump.js +573 -0
  77. package/bin/runners/lib/extractors/fastify-routes.js +426 -0
  78. package/bin/runners/lib/extractors/index.js +363 -0
  79. package/bin/runners/lib/extractors/next-routes.js +524 -0
  80. package/bin/runners/lib/extractors/proof-graph.js +431 -0
  81. package/bin/runners/lib/extractors/route-matcher.js +451 -0
  82. package/bin/runners/lib/extractors/truthpack-v2.js +377 -0
  83. package/bin/runners/lib/extractors/ui-bindings.js +547 -0
  84. package/bin/runners/lib/findings-schema.js +281 -0
  85. package/bin/runners/lib/html-report.js +650 -0
  86. package/bin/runners/lib/missions/templates.js +45 -0
  87. package/bin/runners/lib/policy.js +295 -0
  88. package/bin/runners/lib/reality/correlation-detectors.js +359 -0
  89. package/bin/runners/lib/reality/index.js +318 -0
  90. package/bin/runners/lib/reality/request-hashing.js +416 -0
  91. package/bin/runners/lib/reality/request-mapper.js +453 -0
  92. package/bin/runners/lib/reality/safety-rails.js +463 -0
  93. package/bin/runners/lib/reality/semantic-snapshot.js +408 -0
  94. package/bin/runners/lib/reality/toast-detector.js +393 -0
  95. package/bin/runners/lib/route-truth.js +10 -10
  96. package/bin/runners/lib/schema-validator.js +350 -0
  97. package/bin/runners/lib/schemas/contracts.schema.json +160 -0
  98. package/bin/runners/lib/schemas/finding.schema.json +100 -0
  99. package/bin/runners/lib/schemas/mission-pack.schema.json +206 -0
  100. package/bin/runners/lib/schemas/proof-graph.schema.json +176 -0
  101. package/bin/runners/lib/schemas/reality-report.schema.json +162 -0
  102. package/bin/runners/lib/schemas/share-pack.schema.json +180 -0
  103. package/bin/runners/lib/schemas/ship-report.schema.json +117 -0
  104. package/bin/runners/lib/schemas/truthpack-v2.schema.json +303 -0
  105. package/bin/runners/lib/schemas/validator.js +438 -0
  106. package/bin/runners/lib/verdict-engine.js +628 -0
  107. package/bin/runners/runAIAgent.js +228 -1
  108. package/bin/runners/runBadge.js +181 -1
  109. package/bin/runners/runCtxDiff.js +301 -0
  110. package/bin/runners/runInitGha.js +78 -15
  111. package/bin/runners/runLaunch.js +180 -1
  112. package/bin/runners/runProve.js +23 -0
  113. package/bin/runners/runReplay.js +114 -84
  114. package/bin/runners/runScan.js +111 -32
  115. package/bin/runners/runShip.js +23 -2
  116. package/bin/runners/runTruthpack.js +9 -7
  117. package/bin/runners/runValidate.js +161 -1
  118. package/bin/vibecheck.js +6 -1
  119. package/package.json +1 -1
@@ -0,0 +1,199 @@
1
+ /**
2
+ * Route Contract Builder
3
+ * Builds routes.json contract from truthpack
4
+ */
5
+
6
+ "use strict";
7
+
8
+ const crypto = require("crypto");
9
+
10
+ function sha256(text) {
11
+ return crypto.createHash("sha256").update(text).digest("hex").slice(0, 16);
12
+ }
13
+
14
+ /**
15
+ * Build routes contract from truthpack
16
+ */
17
+ function buildRouteContract(truthpack) {
18
+ const contract = {
19
+ version: "1.0.0",
20
+ generatedAt: new Date().toISOString(),
21
+ routes: []
22
+ };
23
+
24
+ const serverRoutes = truthpack?.routes?.server || [];
25
+
26
+ for (const route of serverRoutes) {
27
+ const routeSpec = {
28
+ id: `route_${sha256(route.method + "_" + route.path)}`,
29
+ method: route.method,
30
+ path: route.path,
31
+ handler: route.handler || "unknown",
32
+ auth: inferAuthRequirement(route, truthpack),
33
+ roles: inferRoles(route, truthpack),
34
+ confidence: route.confidence || "med",
35
+ evidence: route.evidence || []
36
+ };
37
+
38
+ contract.routes.push(routeSpec);
39
+ }
40
+
41
+ // Deterministic output: sort routes by method + path
42
+ contract.routes.sort((a, b) => {
43
+ const keyA = `${a.method}_${a.path}`;
44
+ const keyB = `${b.method}_${b.path}`;
45
+ return keyA.localeCompare(keyB);
46
+ });
47
+
48
+ return contract;
49
+ }
50
+
51
+ /**
52
+ * Infer auth requirement from route and truthpack
53
+ */
54
+ function inferAuthRequirement(route, truthpack) {
55
+ const authPatterns = truthpack?.auth?.nextMatcherPatterns || [];
56
+ const path = route.path;
57
+
58
+ // Check if path matches any protected pattern
59
+ for (const pattern of authPatterns) {
60
+ if (matchesPattern(path, pattern)) {
61
+ return "required";
62
+ }
63
+ }
64
+
65
+ // Check for auth hooks in Fastify
66
+ if (route.hooks?.includes("onRequest") || route.hooks?.includes("preHandler")) {
67
+ return "required";
68
+ }
69
+
70
+ // Check for public API patterns
71
+ if (path.includes("/public/") || path.includes("/health") || path.includes("/status")) {
72
+ return "none";
73
+ }
74
+
75
+ return "optional";
76
+ }
77
+
78
+ /**
79
+ * Infer roles from route metadata
80
+ */
81
+ function inferRoles(route, truthpack) {
82
+ const roles = [];
83
+
84
+ // Check for admin patterns in path
85
+ if (route.path.includes("/admin")) {
86
+ roles.push("admin");
87
+ }
88
+
89
+ // Check handler for role patterns
90
+ const handler = route.handler || "";
91
+ if (handler.includes("admin")) {
92
+ roles.push("admin");
93
+ }
94
+
95
+ return roles.length > 0 ? roles : undefined;
96
+ }
97
+
98
+ function matchesPattern(path, pattern) {
99
+ // Simple pattern matching
100
+ const normPattern = pattern.replace(/\*/g, ".*").replace(/\//g, "\\/");
101
+ try {
102
+ const rx = new RegExp(`^${normPattern}`, "i");
103
+ return rx.test(path);
104
+ } catch {
105
+ return false;
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Validate code against route contract
111
+ */
112
+ function validateAgainstRouteContract(contract, clientRefs) {
113
+ const violations = [];
114
+ const contractPaths = new Map(contract.routes.map(r => [`${r.method}_${r.path}`, r]));
115
+
116
+ for (const ref of clientRefs) {
117
+ const key = `${ref.method}_${ref.path}`;
118
+ const wildcardKey = `*_${ref.path}`;
119
+
120
+ if (!contractPaths.has(key) && !contractPaths.has(wildcardKey)) {
121
+ // Check parameterized match
122
+ const match = findParameterizedMatch(contract.routes, ref.method, ref.path);
123
+
124
+ if (!match) {
125
+ violations.push({
126
+ type: "undeclared_route",
127
+ severity: "BLOCK",
128
+ route: { method: ref.method, path: ref.path },
129
+ source: ref.source,
130
+ message: `Route ${ref.method} ${ref.path} used in client but not declared in contract`,
131
+ evidence: ref.evidence || []
132
+ });
133
+ }
134
+ }
135
+ }
136
+
137
+ return violations;
138
+ }
139
+
140
+ function findParameterizedMatch(routes, method, path) {
141
+ for (const r of routes) {
142
+ if (r.method !== "*" && r.method !== method) continue;
143
+ if (matchesParameterized(r.path, path)) return r;
144
+ }
145
+ return null;
146
+ }
147
+
148
+ function matchesParameterized(pattern, actual) {
149
+ const patternParts = pattern.split("/").filter(Boolean);
150
+ const actualParts = actual.split("/").filter(Boolean);
151
+
152
+ if (patternParts.length !== actualParts.length) return false;
153
+
154
+ for (let i = 0; i < patternParts.length; i++) {
155
+ const p = patternParts[i];
156
+ if (p.startsWith(":") || p.startsWith("*")) continue;
157
+ if (p !== actualParts[i]) return false;
158
+ }
159
+ return true;
160
+ }
161
+
162
+ /**
163
+ * Diff two route contracts
164
+ */
165
+ function diffRouteContracts(before, after) {
166
+ const diff = {
167
+ added: [],
168
+ removed: [],
169
+ changed: []
170
+ };
171
+
172
+ const beforeMap = new Map(before.routes.map(r => [r.id, r]));
173
+ const afterMap = new Map(after.routes.map(r => [r.id, r]));
174
+
175
+ for (const [id, route] of afterMap) {
176
+ if (!beforeMap.has(id)) {
177
+ diff.added.push(route);
178
+ } else {
179
+ const prev = beforeMap.get(id);
180
+ if (prev.auth !== route.auth || JSON.stringify(prev.roles) !== JSON.stringify(route.roles)) {
181
+ diff.changed.push({ before: prev, after: route });
182
+ }
183
+ }
184
+ }
185
+
186
+ for (const [id, route] of beforeMap) {
187
+ if (!afterMap.has(id)) {
188
+ diff.removed.push(route);
189
+ }
190
+ }
191
+
192
+ return diff;
193
+ }
194
+
195
+ module.exports = {
196
+ buildRouteContract,
197
+ validateAgainstRouteContract,
198
+ diffRouteContracts
199
+ };