@vibecheckai/cli 3.0.2 → 3.0.3

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 (68) hide show
  1. package/package.json +9 -1
  2. package/bin/cli-hygiene.js +0 -241
  3. package/bin/guardrail.js +0 -834
  4. package/bin/runners/cli-utils.js +0 -1070
  5. package/bin/runners/context/ai-task-decomposer.js +0 -337
  6. package/bin/runners/context/analyzer.js +0 -462
  7. package/bin/runners/context/api-contracts.js +0 -427
  8. package/bin/runners/context/context-diff.js +0 -342
  9. package/bin/runners/context/context-pruner.js +0 -291
  10. package/bin/runners/context/dependency-graph.js +0 -414
  11. package/bin/runners/context/generators/claude.js +0 -107
  12. package/bin/runners/context/generators/codex.js +0 -108
  13. package/bin/runners/context/generators/copilot.js +0 -119
  14. package/bin/runners/context/generators/cursor.js +0 -514
  15. package/bin/runners/context/generators/mcp.js +0 -151
  16. package/bin/runners/context/generators/windsurf.js +0 -180
  17. package/bin/runners/context/git-context.js +0 -302
  18. package/bin/runners/context/index.js +0 -1042
  19. package/bin/runners/context/insights.js +0 -173
  20. package/bin/runners/context/mcp-server/generate-rules.js +0 -337
  21. package/bin/runners/context/mcp-server/index.js +0 -1176
  22. package/bin/runners/context/mcp-server/package.json +0 -24
  23. package/bin/runners/context/memory.js +0 -200
  24. package/bin/runners/context/monorepo.js +0 -215
  25. package/bin/runners/context/multi-repo-federation.js +0 -404
  26. package/bin/runners/context/patterns.js +0 -253
  27. package/bin/runners/context/proof-context.js +0 -972
  28. package/bin/runners/context/security-scanner.js +0 -303
  29. package/bin/runners/context/semantic-search.js +0 -350
  30. package/bin/runners/context/shared.js +0 -264
  31. package/bin/runners/context/team-conventions.js +0 -310
  32. package/bin/runners/lib/ai-bridge.js +0 -416
  33. package/bin/runners/lib/analysis-core.js +0 -271
  34. package/bin/runners/lib/analyzers.js +0 -541
  35. package/bin/runners/lib/audit-bridge.js +0 -391
  36. package/bin/runners/lib/auth-truth.js +0 -193
  37. package/bin/runners/lib/auth.js +0 -215
  38. package/bin/runners/lib/backup.js +0 -62
  39. package/bin/runners/lib/billing.js +0 -107
  40. package/bin/runners/lib/claims.js +0 -118
  41. package/bin/runners/lib/cli-ui.js +0 -540
  42. package/bin/runners/lib/compliance-bridge-new.js +0 -0
  43. package/bin/runners/lib/compliance-bridge.js +0 -165
  44. package/bin/runners/lib/contracts/auth-contract.js +0 -194
  45. package/bin/runners/lib/contracts/env-contract.js +0 -178
  46. package/bin/runners/lib/contracts/external-contract.js +0 -198
  47. package/bin/runners/lib/contracts/guard.js +0 -168
  48. package/bin/runners/lib/contracts/index.js +0 -89
  49. package/bin/runners/lib/contracts/plan-validator.js +0 -311
  50. package/bin/runners/lib/contracts/route-contract.js +0 -192
  51. package/bin/runners/lib/detect.js +0 -89
  52. package/bin/runners/lib/doctor/autofix.js +0 -254
  53. package/bin/runners/lib/doctor/index.js +0 -37
  54. package/bin/runners/lib/doctor/modules/dependencies.js +0 -325
  55. package/bin/runners/lib/doctor/modules/index.js +0 -46
  56. package/bin/runners/lib/doctor/modules/network.js +0 -250
  57. package/bin/runners/lib/doctor/modules/project.js +0 -312
  58. package/bin/runners/lib/doctor/modules/runtime.js +0 -224
  59. package/bin/runners/lib/doctor/modules/security.js +0 -348
  60. package/bin/runners/lib/doctor/modules/system.js +0 -213
  61. package/bin/runners/lib/doctor/modules/vibecheck.js +0 -394
  62. package/bin/runners/lib/doctor/reporter.js +0 -262
  63. package/bin/runners/lib/doctor/service.js +0 -262
  64. package/bin/runners/lib/doctor/types.js +0 -113
  65. package/bin/runners/lib/doctor/ui.js +0 -263
  66. package/bin/runners/lib/doctor-enhanced.js +0 -233
  67. package/bin/runners/lib/doctor-v2.js +0 -608
  68. package/bin/runners/lib/enforcement.js +0 -72
@@ -1,427 +0,0 @@
1
- /**
2
- * API Contract Extraction Module
3
- * Extracts OpenAPI and GraphQL schemas for context
4
- */
5
-
6
- const fs = require("fs");
7
- const path = require("path");
8
-
9
- /**
10
- * Find files recursively (local helper)
11
- */
12
- function findFiles(dir, extensions, maxDepth = 5, currentDepth = 0) {
13
- if (currentDepth >= maxDepth || !fs.existsSync(dir)) return [];
14
-
15
- const files = [];
16
- try {
17
- const entries = fs.readdirSync(dir, { withFileTypes: true });
18
- for (const entry of entries) {
19
- const fullPath = path.join(dir, entry.name);
20
- if (entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules") {
21
- files.push(...findFiles(fullPath, extensions, maxDepth, currentDepth + 1));
22
- } else if (entry.isFile() && extensions.some(ext => entry.name.endsWith(ext))) {
23
- files.push(fullPath);
24
- }
25
- }
26
- } catch {}
27
- return files;
28
- }
29
-
30
- /**
31
- * Extract OpenAPI/Swagger specifications
32
- */
33
- function extractOpenAPISpecs(projectPath) {
34
- const specs = [];
35
-
36
- // Look for OpenAPI files
37
- const openAPIFiles = findFiles(projectPath, [
38
- ".json", ".yaml", ".yml"
39
- ]).filter(file => {
40
- const content = fs.readFileSync(file, "utf-8");
41
- return content.includes("openapi") || content.includes("swagger");
42
- });
43
-
44
- for (const file of openAPIFiles) {
45
- try {
46
- const content = fs.readFileSync(file, "utf-8");
47
- let spec;
48
-
49
- if (file.endsWith(".json")) {
50
- spec = JSON.parse(content);
51
- } else {
52
- // Simple YAML parser for basic specs
53
- spec = parseSimpleYAML(content);
54
- }
55
-
56
- if (spec && (spec.openapi || spec.swagger)) {
57
- // Extract key information
58
- const extracted = {
59
- file: path.relative(projectPath, file).replace(/\\/g, "/"),
60
- version: spec.openapi || spec.swagger,
61
- title: spec.info?.title || "Untitled API",
62
- description: spec.info?.description || "",
63
- baseUrl: spec.servers?.[0]?.url || "",
64
- paths: Object.keys(spec.paths || {}),
65
- schemas: Object.keys(spec.components?.schemas || {}),
66
- endpoints: [],
67
- };
68
-
69
- // Extract endpoint details
70
- for (const [path, methods] of Object.entries(spec.paths || {})) {
71
- for (const [method, details] of Object.entries(methods)) {
72
- if (typeof details === "object" && details.operationId) {
73
- extracted.endpoints.push({
74
- method: method.toUpperCase(),
75
- path,
76
- operationId: details.operationId,
77
- summary: details.summary || "",
78
- tags: details.tags || [],
79
- });
80
- }
81
- }
82
- }
83
-
84
- specs.push(extracted);
85
- }
86
- } catch {}
87
- }
88
-
89
- return specs;
90
- }
91
-
92
- /**
93
- * Simple YAML parser for basic specs
94
- */
95
- function parseSimpleYAML(content) {
96
- const lines = content.split("\n");
97
- const result = {};
98
- let currentSection = result;
99
- const sectionStack = [result];
100
- let indent = 0;
101
-
102
- for (const line of lines) {
103
- if (line.trim() === "" || line.trim().startsWith("#")) continue;
104
-
105
- const currentIndent = line.match(/^ */)[0].length;
106
- const trimmed = line.trim();
107
-
108
- if (trimmed.includes(":")) {
109
- const [key, ...valueParts] = trimmed.split(":");
110
- const value = valueParts.join(":").trim();
111
-
112
- // Adjust section stack based on indentation
113
- if (currentIndent < indent) {
114
- sectionStack.pop();
115
- currentSection = sectionStack[sectionStack.length - 1];
116
- }
117
-
118
- if (value) {
119
- // Simple value
120
- currentSection[key.trim()] = value.replace(/['"]/g, "");
121
- } else {
122
- // New section
123
- currentSection[key.trim()] = {};
124
- sectionStack.push(currentSection[key.trim()]);
125
- currentSection = currentSection[key.trim()];
126
- }
127
-
128
- indent = currentIndent;
129
- }
130
- }
131
-
132
- return result;
133
- }
134
-
135
- /**
136
- * Extract GraphQL schemas
137
- */
138
- function extractGraphQLSchemas(projectPath) {
139
- const schemas = [];
140
-
141
- // Look for GraphQL files
142
- const graphqlFiles = findFiles(projectPath, [
143
- ".graphql", ".gql"
144
- ]);
145
-
146
- // Also check for schema definitions in JS/TS files
147
- const jsFiles = findFiles(projectPath, [
148
- ".ts", ".tsx", ".js", ".jsx"
149
- ]).filter(file => {
150
- const content = fs.readFileSync(file, "utf-8");
151
- return content.includes("gql`") || content.includes("GraphQLSchema") || content.includes("typeDefs");
152
- });
153
-
154
- // Process .graphql files
155
- for (const file of graphqlFiles) {
156
- try {
157
- const content = fs.readFileSync(file, "utf-8");
158
- const types = extractGraphQLTypes(content);
159
-
160
- schemas.push({
161
- file: path.relative(projectPath, file).replace(/\\/g, "/"),
162
- type: "schema",
163
- types,
164
- queries: types.filter(t => t.type === "Query" || t.name.startsWith("query")),
165
- mutations: types.filter(t => t.type === "Mutation" || t.name.startsWith("mutation")),
166
- subscriptions: types.filter(t => t.type === "Subscription" || t.name.startsWith("subscription")),
167
- });
168
- } catch {}
169
- }
170
-
171
- // Process JS/TS files with embedded schemas
172
- for (const file of jsFiles) {
173
- try {
174
- const content = fs.readFileSync(file, "utf-8");
175
- const extracted = extractEmbeddedGraphQL(content);
176
-
177
- if (extracted.schemas.length > 0) {
178
- schemas.push({
179
- file: path.relative(projectPath, file).replace(/\\/g, "/"),
180
- type: "embedded",
181
- schemas: extracted.schemas,
182
- resolvers: extracted.resolvers,
183
- });
184
- }
185
- } catch {}
186
- }
187
-
188
- return schemas;
189
- }
190
-
191
- /**
192
- * Extract types from GraphQL schema
193
- */
194
- function extractGraphQLTypes(content) {
195
- const types = [];
196
- const lines = content.split("\n");
197
- let currentType = null;
198
-
199
- for (const line of lines) {
200
- const trimmed = line.trim();
201
-
202
- if (trimmed.startsWith("type ") || trimmed.startsWith("interface ") ||
203
- trimmed.startsWith("input ") || trimmed.startsWith("enum ")) {
204
- const parts = trimmed.split(/\s+/);
205
- currentType = {
206
- type: parts[0],
207
- name: parts[1],
208
- fields: [],
209
- };
210
- types.push(currentType);
211
- } else if (currentType && trimmed && !trimmed.startsWith("#")) {
212
- if (trimmed === "}") {
213
- currentType = null;
214
- } else if (trimmed.includes(":")) {
215
- const [fieldName, fieldType] = trimmed.split(":").map(s => s.trim());
216
- if (fieldName && fieldType) {
217
- currentType.fields.push({
218
- name: fieldName,
219
- type: fieldType.replace(/[!]/g, ""),
220
- required: fieldType.includes("!"),
221
- });
222
- }
223
- }
224
- }
225
- }
226
-
227
- return types;
228
- }
229
-
230
- /**
231
- * Extract embedded GraphQL from JS/TS
232
- */
233
- function extractEmbeddedGraphQL(content) {
234
- const schemas = [];
235
- const resolvers = [];
236
-
237
- // Extract template literals
238
- const gqlMatches = content.match(/gql`([^`]+)`/g) || [];
239
-
240
- for (const match of gqlMatches) {
241
- const schema = match.replace(/gql`([^`]+)`/, "$1");
242
- const types = extractGraphQLTypes(schema);
243
-
244
- schemas.push({
245
- content: schema,
246
- types,
247
- });
248
- }
249
-
250
- // Look for typeDefs assignments
251
- const typeDefMatches = content.match(/typeDefs\s*[:=]\s*`([^`]+)`/g) || [];
252
-
253
- for (const match of typeDefMatches) {
254
- const schema = match.replace(/typeDefs\s*[:=]\s*`([^`]+)`/, "$1");
255
- const types = extractGraphQLTypes(schema);
256
-
257
- schemas.push({
258
- content: schema,
259
- types,
260
- });
261
- }
262
-
263
- // Look for resolvers
264
- const resolverMatches = content.match(/resolvers\s*[:=]\s*{([^}]+)}/gs) || [];
265
-
266
- for (const match of resolverMatches) {
267
- resolvers.push({
268
- content: match,
269
- });
270
- }
271
-
272
- return { schemas, resolvers };
273
- }
274
-
275
- /**
276
- * Extract API route patterns from Express/Next.js
277
- */
278
- function extractAPIRoutes(projectPath) {
279
- const routes = [];
280
-
281
- // Look for API route files
282
- const apiFiles = findFiles(projectPath, [
283
- ".ts", ".tsx", ".js", ".jsx"
284
- ]).filter(file => {
285
- const relativePath = path.relative(projectPath, file).replace(/\\/g, "/");
286
- return relativePath.includes("/api/") || relativePath.includes("/routes/");
287
- });
288
-
289
- for (const file of apiFiles) {
290
- try {
291
- const content = fs.readFileSync(file, "utf-8");
292
- const extracted = extractRouteInfo(content, file);
293
-
294
- if (extracted.routes.length > 0) {
295
- routes.push({
296
- file: path.relative(projectPath, file).replace(/\\/g, "/"),
297
- routes: extracted.routes,
298
- middleware: extracted.middleware,
299
- validation: extracted.validation,
300
- });
301
- }
302
- } catch {}
303
- }
304
-
305
- return routes;
306
- }
307
-
308
- /**
309
- * Extract route information from file
310
- */
311
- function extractRouteInfo(content, filePath) {
312
- const routes = [];
313
- const middleware = [];
314
- const validation = [];
315
-
316
- // Extract Express routes
317
- const expressMatches = content.match(/\.(get|post|put|delete|patch)\s*\(\s*['"]([^'"]+)['"]/g) || [];
318
-
319
- for (const match of expressMatches) {
320
- const parts = match.match(/\.(get|post|put|delete|patch)\s*\(\s*['"]([^'"]+)['"]/);
321
- if (parts) {
322
- routes.push({
323
- method: parts[1].toUpperCase(),
324
- path: parts[2],
325
- framework: "Express",
326
- });
327
- }
328
- }
329
-
330
- // Extract Next.js API routes
331
- if (filePath.includes("/api/")) {
332
- const relativePath = path.relative(process.cwd(), filePath).replace(/\\/g, "/");
333
- const routePath = relativePath
334
- .replace(/\/api\//, "/")
335
- .replace(/\.(ts|tsx|js|jsx)$/, "");
336
-
337
- // Look for HTTP method exports
338
- const methods = ["GET", "POST", "PUT", "DELETE", "PATCH"];
339
- for (const method of methods) {
340
- if (content.includes(`export async function ${method}`) ||
341
- content.includes(`export function ${method}`)) {
342
- routes.push({
343
- method,
344
- path: routePath,
345
- framework: "Next.js",
346
- });
347
- }
348
- }
349
- }
350
-
351
- // Extract middleware usage
352
- if (content.includes("cors")) middleware.push("cors");
353
- if (content.includes("helmet")) middleware.push("helmet");
354
- if (content.includes("auth")) middleware.push("auth");
355
- if (content.includes("validate") || content.includes("zod")) validation.push("zod");
356
- if (content.includes("joi")) validation.push("joi");
357
-
358
- return { routes, middleware, validation };
359
- }
360
-
361
- /**
362
- * Generate API context summary
363
- */
364
- function generateAPIContext(projectPath) {
365
- const openAPI = extractOpenAPISpecs(projectPath);
366
- const graphql = extractGraphQLSchemas(projectPath);
367
- const routes = extractAPIRoutes(projectPath);
368
-
369
- return {
370
- summary: {
371
- hasOpenAPI: openAPI.length > 0,
372
- openAPICount: openAPI.length,
373
- hasGraphQL: graphql.length > 0,
374
- graphqlCount: graphql.length,
375
- hasCustomRoutes: routes.length > 0,
376
- routeCount: routes.reduce((sum, r) => sum + r.routes.length, 0),
377
- },
378
- openAPI,
379
- graphql,
380
- routes,
381
- recommendations: generateAPIRecommendations(openAPI, graphql, routes),
382
- };
383
- }
384
-
385
- /**
386
- * Generate API recommendations
387
- */
388
- function generateAPIRecommendations(openAPI, graphql, routes) {
389
- const recommendations = [];
390
-
391
- if (openAPI.length === 0 && graphql.length === 0 && routes.length > 0) {
392
- recommendations.push({
393
- type: "documentation",
394
- message: "Consider adding OpenAPI/Swagger specification for better API documentation",
395
- });
396
- }
397
-
398
- if (routes.length > 0) {
399
- const hasValidation = routes.some(r => r.validation.length > 0);
400
- if (!hasValidation) {
401
- recommendations.push({
402
- type: "validation",
403
- message: "Add input validation to API routes (zod, joi, etc.)",
404
- });
405
- }
406
- }
407
-
408
- const totalEndpoints = openAPI.reduce((sum, s) => sum + s.endpoints.length, 0) +
409
- graphql.reduce((sum, s) => sum + (s.queries?.length || 0) + (s.mutations?.length || 0), 0) +
410
- routes.reduce((sum, r) => sum + r.routes.length, 0);
411
-
412
- if (totalEndpoints > 20) {
413
- recommendations.push({
414
- type: "organization",
415
- message: "Consider organizing APIs into modules or microservices",
416
- });
417
- }
418
-
419
- return recommendations;
420
- }
421
-
422
- module.exports = {
423
- extractOpenAPISpecs,
424
- extractGraphQLSchemas,
425
- extractAPIRoutes,
426
- generateAPIContext,
427
- };