vibezcheck 0.5.12 → 0.5.13
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/dist/ai-sdk/index.js +11 -0
- package/dist/ai-sdk/index.js.map +1 -1
- package/dist/ai-sdk/index.mjs +11 -0
- package/dist/ai-sdk/index.mjs.map +1 -1
- package/dist/ai-sdk/middleware.js +11 -0
- package/dist/ai-sdk/middleware.js.map +1 -1
- package/dist/ai-sdk/middleware.mjs +11 -0
- package/dist/ai-sdk/middleware.mjs.map +1 -1
- package/dist/billing/index.js +11 -0
- package/dist/billing/index.js.map +1 -1
- package/dist/billing/index.mjs +11 -0
- package/dist/billing/index.mjs.map +1 -1
- package/dist/cli/index.js +8 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +8 -1
- package/dist/cli/index.mjs.map +1 -1
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -0
- package/dist/index.mjs.map +1 -1
- package/dist/meter/index.js +11 -0
- package/dist/meter/index.js.map +1 -1
- package/dist/meter/index.mjs +11 -0
- package/dist/meter/index.mjs.map +1 -1
- package/dist/pricing/index.js +11 -0
- package/dist/pricing/index.js.map +1 -1
- package/dist/pricing/index.mjs +11 -0
- package/dist/pricing/index.mjs.map +1 -1
- package/manifest/pricing-v1.json +4904 -974
- package/package.json +2 -1
package/dist/cli/index.js
CHANGED
|
@@ -62,6 +62,10 @@ var MODEL_PRICING_TABLE = {
|
|
|
62
62
|
"text-embedding-3-large": { inputPer1M: 0.13, outputPer1M: 0 },
|
|
63
63
|
"text-embedding-ada-002": { inputPer1M: 0.1, outputPer1M: 0 },
|
|
64
64
|
// --- Anthropic (Modern & Extended Thinking) ---
|
|
65
|
+
"claude-haiku-5.5": { inputPer1M: 0.1, outputPer1M: 0.5, cachedInputPer1M: 0.01 },
|
|
66
|
+
"claude-sonnet-5.5": { inputPer1M: 2, outputPer1M: 10, cachedInputPer1M: 0.1 },
|
|
67
|
+
"claude-opus-5.5": { inputPer1M: 4, outputPer1M: 20, cachedInputPer1M: 0.2 },
|
|
68
|
+
"claude-opus-5.5-fast": { inputPer1M: 8, outputPer1M: 40, cachedInputPer1M: 0.4 },
|
|
65
69
|
"claude-3-7-sonnet": { inputPer1M: 0.59, outputPer1M: 2.93, cachedInputPer1M: 0.3 },
|
|
66
70
|
"claude-sonnet-5": { inputPer1M: 2, outputPer1M: 10, cachedInputPer1M: 0.3 },
|
|
67
71
|
"claude-3-5-sonnet": { inputPer1M: 3, outputPer1M: 15, cachedInputPer1M: 0.3 },
|
|
@@ -76,6 +80,8 @@ var MODEL_PRICING_TABLE = {
|
|
|
76
80
|
"claude-2.0": { inputPer1M: 8, outputPer1M: 24 },
|
|
77
81
|
"claude-instant-1.2": { inputPer1M: 1.63, outputPer1M: 5.51 },
|
|
78
82
|
// --- Google Gemini (Modern & Thoughts) ---
|
|
83
|
+
"gemini-3.8-flash": { inputPer1M: 0.75, outputPer1M: 3.75, cachedInputPer1M: 0.075 },
|
|
84
|
+
"gemini-nano-banana-2.1": { inputPer1M: 1.5, outputPer1M: 7.5, cachedInputPer1M: 0.15 },
|
|
79
85
|
"gemini-3.7-flash": { inputPer1M: 0.75, outputPer1M: 3.75, cachedInputPer1M: 0.18 },
|
|
80
86
|
"gemini-3.1-pro": { inputPer1M: 2, outputPer1M: 12, cachedInputPer1M: 0.5 },
|
|
81
87
|
"gemini-3.5-flash": { inputPer1M: 1.5, outputPer1M: 9, cachedInputPer1M: 0.38 },
|
|
@@ -98,6 +104,7 @@ var MODEL_PRICING_TABLE = {
|
|
|
98
104
|
"grok-2-vision": { inputPer1M: 2, outputPer1M: 10 },
|
|
99
105
|
"grok-beta": { inputPer1M: 5, outputPer1M: 15 },
|
|
100
106
|
// --- Mistral ---
|
|
107
|
+
"mistral-large-4": { inputPer1M: 0.68, outputPer1M: 2.09, cachedInputPer1M: 0.07 },
|
|
101
108
|
"mistral-large-3": { inputPer1M: 2, outputPer1M: 6 },
|
|
102
109
|
"mistral-large-latest": { inputPer1M: 2, outputPer1M: 6 },
|
|
103
110
|
"mistral-large-2411": { inputPer1M: 2, outputPer1M: 6 },
|
|
@@ -662,7 +669,7 @@ function getCliVersion() {
|
|
|
662
669
|
}
|
|
663
670
|
} catch {
|
|
664
671
|
}
|
|
665
|
-
return "0.5.
|
|
672
|
+
return "0.5.13";
|
|
666
673
|
}
|
|
667
674
|
function printBanner() {
|
|
668
675
|
console.log(`
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/index.ts","../../src/pricing/table.ts","../../src/cli/audit.ts","../../src/cli/examples.ts"],"sourcesContent":["#!/usr/bin/env node\r\n\r\nimport fs from 'fs';\r\nimport path from 'path';\r\nimport readline from 'readline';\r\nimport { MODEL_PRICING_TABLE } from '../pricing/table';\r\nimport { runAudit, displayAuditReport } from './audit';\r\nimport { handleExamplesCommand } from './examples';\r\n\r\nconst args = process.argv.slice(2);\r\nconst command = args[0] || 'init';\r\n\r\nfunction getCliVersion(): string {\r\n try {\r\n const candidates = [\r\n path.resolve(__dirname, '../../package.json'),\r\n path.resolve(__dirname, '../package.json'),\r\n path.resolve(__dirname, './package.json'),\r\n ];\r\n for (const p of candidates) {\r\n if (fs.existsSync(p)) {\r\n const pkg = JSON.parse(fs.readFileSync(p, 'utf-8'));\r\n if (pkg.version) return pkg.version;\r\n }\r\n }\r\n } catch {}\r\n return '0.5.12';\r\n}\r\n\r\nfunction printBanner() {\r\n console.log(`\r\n\\x1b[38;2;212;255;50m✦\\x1b[0m \\x1b[1mvibezcheck CLI\\x1b[0m \\x1b[90mv${getCliVersion()}\\x1b[0m\r\n\\x1b[90mThe 1-line Token Metering & Cost Intelligence Engine for LLMs\\x1b[0m\r\n`);\r\n}\r\n\r\nasync function prompt(question: string, defaultVal: string = ''): Promise<string> {\r\n const rl = readline.createInterface({\r\n input: process.stdin,\r\n output: process.stdout,\r\n });\r\n\r\n return new Promise((resolve) => {\r\n const promptText = defaultVal\r\n ? `\\x1b[32m?\\x1b[0m \\x1b[1m${question}\\x1b[0m \\x1b[90m(${defaultVal})\\x1b[0m: `\r\n : `\\x1b[32m?\\x1b[0m \\x1b[1m${question}\\x1b[0m: `;\r\n\r\n rl.question(promptText, (answer) => {\r\n rl.close();\r\n resolve(answer.trim() || defaultVal);\r\n });\r\n });\r\n}\r\n\r\n/**\r\n * Command: npx vibezcheck init\r\n */\r\nasync function handleInit() {\r\n printBanner();\r\n console.log('\\x1b[1m✦ VibezCheck Project Setup Wizard\\x1b[0m\\n');\r\n\r\n const cwd = process.cwd();\r\n\r\n // Detect project structure\r\n const isNextAppRouter = fs.existsSync(path.join(cwd, 'app'));\r\n const isNextPagesRouter = fs.existsSync(path.join(cwd, 'pages'));\r\n const isSrcDir = fs.existsSync(path.join(cwd, 'src', 'app'));\r\n\r\n console.log(`\\x1b[90mProject directory: ${cwd}\\x1b[0m`);\r\n if (isNextAppRouter || isSrcDir) {\r\n console.log('\\x1b[32m✓ Detected Next.js App Router project\\x1b[0m\\n');\r\n }\r\n\r\n // 1. Prompt for API Keys\r\n const defaultGateway = 'vck_demo_key';\r\n const gatewayKey = await prompt('Enter your OpenAI or AI Gateway API Key', defaultGateway);\r\n\r\n // 2. Create / Update .env.local\r\n const envPath = path.join(cwd, '.env.local');\r\n const envContent = `# VibezCheck AI Configuration\r\nOPENAI_API_KEY=${gatewayKey}\r\nAI_GATEWAY_API_KEY=${gatewayKey}\r\n`;\r\n\r\n fs.writeFileSync(envPath, envContent, { flag: 'w' });\r\n console.log(`\\x1b[32m✓ Created/updated .env.local\\x1b[0m`);\r\n\r\n // 3. Create Sample API Route (app/api/chat/route.ts)\r\n const apiDir = isSrcDir\r\n ? path.join(cwd, 'src', 'app', 'api', 'chat')\r\n : path.join(cwd, 'app', 'api', 'chat');\r\n\r\n fs.mkdirSync(apiDir, { recursive: true });\r\n const routePath = path.join(apiDir, 'route.ts');\r\n\r\n const routeContent = `import { streamText } from 'ai';\r\nimport { openai } from '@ai-sdk/openai';\r\nimport { vibezcheck } from 'vibezcheck';\r\n\r\nexport const runtime = 'nodejs';\r\nexport const dynamic = 'force-dynamic';\r\n\r\nexport async function POST(req: Request) {\r\n const { messages, customerId = 'cus_demo_user' } = await req.json();\r\n\r\n // ⚡ 1-Line Declarative Model Metering\r\n const result = streamText({\r\n model: vibezcheck(openai('gpt-4o-mini'), {\r\n customer: customerId,\r\n pricing: { margin: 1.30 }, // +30% profit markup\r\n safety: { maxCostPerCallUSD: 0.50 }, // Auto-shutoff safety switch\r\n onUsage: (event) => {\r\n console.log(\\`[vibezcheck] Tokens: \\${event.usage.totalTokens} | Cost: $\\${event.cost.totalUSD.toFixed(6)}\\`);\r\n },\r\n }),\r\n messages,\r\n });\r\n\r\n return result.toDataStreamResponse();\r\n}\r\n`;\r\n\r\n fs.writeFileSync(routePath, routeContent, { flag: 'w' });\r\n console.log(`\\x1b[32m✓ Generated metered AI route: ${path.relative(cwd, routePath)}\\x1b[0m`);\r\n\r\n console.log(`\r\n\\x1b[32m\\x1b[1mSetup Complete!\\x1b[0m\r\n\r\n\\x1b[1mNext Steps:\\x1b[0m\r\n 1. Add \\x1b[36m<VibezReceipt />\\x1b[0m under assistant messages:\r\n \\x1b[90mimport { VibezReceipt } from 'vibezcheck/react';\\x1b[0m\r\n\r\n 2. Run your dev server:\r\n \\x1b[33mpnpm dev\\x1b[0m or \\x1b[33mnpm run dev\\x1b[0m\r\n`);\r\n}\r\n\r\n/**\r\n * Command: npx vibezcheck prices\r\n */\r\nfunction handlePrices() {\r\n printBanner();\r\n console.log('\\x1b[1m📊 Official Model Pricing Registry (USD per 1M Tokens):\\x1b[0m\\n');\r\n\r\n console.log(\r\n 'Model'.padEnd(32) +\r\n 'Input / 1M'.padEnd(16) +\r\n 'Output / 1M'.padEnd(16) +\r\n 'Cached / 1M'\r\n );\r\n console.log('-'.repeat(78));\r\n\r\n Object.entries(MODEL_PRICING_TABLE).forEach(([model, rates]) => {\r\n const input = `$${rates.inputPer1M.toFixed(3)}`.padEnd(16);\r\n const output = `$${rates.outputPer1M.toFixed(3)}`.padEnd(16);\r\n const cached = rates.cachedInputPer1M\r\n ? `$${rates.cachedInputPer1M.toFixed(3)}`\r\n : '—';\r\n\r\n console.log(model.padEnd(32) + input + output + cached);\r\n });\r\n}\r\n\r\n/**\r\n * Command: npx vibezcheck doctor\r\n */\r\nfunction handleDoctor() {\r\n printBanner();\r\n console.log('\\x1b[1m🩺 Running VibezCheck System Health Check...\\x1b[0m\\n');\r\n\r\n const cwd = process.cwd();\r\n const envPath = path.join(cwd, '.env.local');\r\n const hasEnv = fs.existsSync(envPath);\r\n\r\n console.log(`Node.js Version: \\x1b[32m${process.version}\\x1b[0m`);\r\n console.log(`Working Directory: \\x1b[90m${cwd}\\x1b[0m`);\r\n console.log(`Environment File: ${hasEnv ? '\\x1b[32m✓ Found (.env.local)\\x1b[0m' : '\\x1b[33m⚠ Missing (.env.local)\\x1b[0m'}`);\r\n console.log(`Telemetry Mode: \\x1b[32m✓ Zero-Dependency In-Memory Active\\x1b[0m`);\r\n\r\n const hasGateway = Boolean(process.env.AI_GATEWAY_API_KEY || process.env.OPENAI_API_KEY);\r\n console.log(`AI Provider Key: ${hasGateway ? '\\x1b[32m✓ Configured\\x1b[0m' : '\\x1b[33m⚠ Missing (Set AI_GATEWAY_API_KEY)\\x1b[0m'}`);\r\n\r\n console.log(`\\n\\x1b[32m✓ VibezCheck engine is healthy and ready to meter!\\x1b[0m\\n`);\r\n}\r\n\r\n/**\r\n * Command: npx vibezcheck audit [--fix] [--ci] [--json] [--dir <path>]\r\n */\r\nasync function handleAudit() {\r\n const fix = args.includes('--fix') || args.includes('-f');\r\n const ci = args.includes('--ci') || args.includes('-s') || args.includes('--strict');\r\n const json = args.includes('--json') || args.includes('-j');\r\n\r\n let dir = process.cwd();\r\n const dirIndex = args.indexOf('--dir') !== -1 ? args.indexOf('--dir') : args.indexOf('-d');\r\n if (dirIndex !== -1 && args[dirIndex + 1]) {\r\n dir = args[dirIndex + 1];\r\n }\r\n\r\n const summary = await runAudit({ dir, fix, ci, json });\r\n await displayAuditReport(summary, { dir, fix, ci, json });\r\n}\r\n\r\n// Router\r\nswitch (command) {\r\n case 'audit':\r\n case 'check':\r\n case 'scan':\r\n handleAudit();\r\n break;\r\n case 'init':\r\n handleInit();\r\n break;\r\n case 'example':\r\n case 'examples':\r\n case 'template':\r\n case 'templates':\r\n handleExamplesCommand(args.slice(1));\r\n break;\r\n case 'prices':\r\n case 'pricing':\r\n handlePrices();\r\n break;\r\n case 'doctor':\r\n case 'health':\r\n handleDoctor();\r\n break;\r\n default:\r\n console.log(`\r\nUnknown command: \\x1b[31m${command}\\x1b[0m\r\n\r\nAvailable commands:\r\n \\x1b[36mvibezcheck examples [name]\\x1b[0m Explore & scaffold official starter templates & scripts\r\n \\x1b[36mvibezcheck audit\\x1b[0m Scan project for unmetered AI routes and runaway loop risks\r\n \\x1b[36mvibezcheck init\\x1b[0m Interactive project setup wizard\r\n \\x1b[36mvibezcheck prices\\x1b[0m Display supported model pricing table\r\n \\x1b[36mvibezcheck doctor\\x1b[0m Diagnose environment and API configurations\r\n`);\r\n break;\r\n}\r\n","import type { ModelPricingRates } from '../types';\r\nimport { getDynamicRate } from './sync';\r\n\r\n/**\r\n * Built-in Registry of Model Pricing (USD per 1 Million Tokens)\r\n * Sourced from official 2026 provider pricing tables.\r\n */\r\nexport const MODEL_PRICING_TABLE: Record<string, ModelPricingRates> = {\r\n // --- OpenAI (Modern & Reasoning) ---\r\n 'gpt-5.6-sol': { inputPer1M: 4.0, outputPer1M: 20.0, cachedInputPer1M: 0.4 },\r\n 'gpt-5.6-terra': { inputPer1M: 2.0, outputPer1M: 12.0, cachedInputPer1M: 0.2 },\r\n 'gpt-5.6-luna': { inputPer1M: 0.2, outputPer1M: 1.2, cachedInputPer1M: 0.02 },\r\n 'gpt-5': { inputPer1M: 4.0, outputPer1M: 20.0, cachedInputPer1M: 0.4 },\r\n 'gpt-5-mini': { inputPer1M: 0.2, outputPer1M: 1.2, cachedInputPer1M: 0.02 },\r\n 'o1': { inputPer1M: 15.0, outputPer1M: 60.0, cachedInputPer1M: 7.5 },\r\n 'o1-mini': { inputPer1M: 1.1, outputPer1M: 4.4, cachedInputPer1M: 0.55 },\r\n 'o3': { inputPer1M: 15.0, outputPer1M: 60.0, cachedInputPer1M: 7.5 },\r\n 'o3-mini': { inputPer1M: 1.1, outputPer1M: 4.4, cachedInputPer1M: 0.55 },\r\n 'gpt-4o': { inputPer1M: 2.5, outputPer1M: 10.0, cachedInputPer1M: 1.25 },\r\n 'gpt-4o-mini': { inputPer1M: 0.15, outputPer1M: 0.6, cachedInputPer1M: 0.075 },\r\n 'gpt-4.5': { inputPer1M: 75.0, outputPer1M: 150.0, cachedInputPer1M: 37.5 },\r\n 'gpt-4.5-preview': { inputPer1M: 75.0, outputPer1M: 150.0, cachedInputPer1M: 37.5 },\r\n 'chatgpt-4o-latest': { inputPer1M: 5.0, outputPer1M: 15.0 },\r\n 'gpt-4.1': { inputPer1M: 2.0, outputPer1M: 8.0, cachedInputPer1M: 1.0 },\r\n 'gpt-4.1-nano': { inputPer1M: 0.1, outputPer1M: 0.4, cachedInputPer1M: 0.05 },\r\n 'gpt-6-astra': { inputPer1M: 5.0, outputPer1M: 25.0, cachedInputPer1M: 0.5 },\r\n 'gpt-6-astra-fast': { inputPer1M: 3.0, outputPer1M: 15.0, cachedInputPer1M: 0.3 },\r\n 'gpt-image-2.5-flare': { inputPer1M: 0.0, outputPer1M: 0.04 },\r\n 'gpt-image-2.5-sunburst': { inputPer1M: 0.0, outputPer1M: 0.08 },\r\n\r\n // --- OpenAI (Legacy & Backward Compatibility) ---\r\n 'gpt-4-turbo': { inputPer1M: 10.0, outputPer1M: 30.0, cachedInputPer1M: 5.0 },\r\n 'gpt-4-turbo-preview': { inputPer1M: 10.0, outputPer1M: 30.0, cachedInputPer1M: 5.0 },\r\n 'gpt-4': { inputPer1M: 30.0, outputPer1M: 60.0 },\r\n 'gpt-4-32k': { inputPer1M: 60.0, outputPer1M: 120.0 },\r\n 'gpt-3.5-turbo': { inputPer1M: 0.5, outputPer1M: 1.5 },\r\n 'gpt-3.5-turbo-16k': { inputPer1M: 3.0, outputPer1M: 4.0 },\r\n 'text-embedding-3-small': { inputPer1M: 0.02, outputPer1M: 0.0 },\r\n 'text-embedding-3-large': { inputPer1M: 0.13, outputPer1M: 0.0 },\r\n 'text-embedding-ada-002': { inputPer1M: 0.10, outputPer1M: 0.0 },\r\n\r\n // --- Anthropic (Modern & Extended Thinking) ---\r\n 'claude-3-7-sonnet': { inputPer1M: 0.59, outputPer1M: 2.93, cachedInputPer1M: 0.3 },\r\n 'claude-sonnet-5': { inputPer1M: 2.0, outputPer1M: 10.0, cachedInputPer1M: 0.3 },\r\n 'claude-3-5-sonnet': { inputPer1M: 3.0, outputPer1M: 15.0, cachedInputPer1M: 0.3 },\r\n 'claude-3-5-haiku': { inputPer1M: 0.8, outputPer1M: 4.0, cachedInputPer1M: 0.08 },\r\n 'haiku-4.5': { inputPer1M: 1.0, outputPer1M: 5.0, cachedInputPer1M: 0.1 },\r\n 'claude-opus-5': { inputPer1M: 5.0, outputPer1M: 25.0, cachedInputPer1M: 1.5 },\r\n 'claude-3-opus': { inputPer1M: 15.0, outputPer1M: 75.0, cachedInputPer1M: 1.5 },\r\n\r\n // --- Anthropic (Legacy & Backward Compatibility) ---\r\n 'claude-3-sonnet': { inputPer1M: 3.0, outputPer1M: 15.0, cachedInputPer1M: 0.3 },\r\n 'claude-3-haiku': { inputPer1M: 0.25, outputPer1M: 1.25, cachedInputPer1M: 0.025 },\r\n 'claude-2.1': { inputPer1M: 8.0, outputPer1M: 24.0 },\r\n 'claude-2.0': { inputPer1M: 8.0, outputPer1M: 24.0 },\r\n 'claude-instant-1.2': { inputPer1M: 1.63, outputPer1M: 5.51 },\r\n\r\n // --- Google Gemini (Modern & Thoughts) ---\r\n 'gemini-3.7-flash': { inputPer1M: 0.75, outputPer1M: 3.75, cachedInputPer1M: 0.18 },\r\n 'gemini-3.1-pro': { inputPer1M: 2.0, outputPer1M: 12.0, cachedInputPer1M: 0.5 },\r\n 'gemini-3.5-flash': { inputPer1M: 1.5, outputPer1M: 9.0, cachedInputPer1M: 0.38 },\r\n 'gemini-3.1-flash-lite': { inputPer1M: 0.25, outputPer1M: 1.5, cachedInputPer1M: 0.06 },\r\n 'gemini-2.5-pro': { inputPer1M: 1.25, outputPer1M: 5.0, cachedInputPer1M: 0.3125 },\r\n 'gemini-2.5-flash': { inputPer1M: 0.15, outputPer1M: 0.6, cachedInputPer1M: 0.0375 },\r\n 'gemini-2.0-flash': { inputPer1M: 0.1, outputPer1M: 0.4, cachedInputPer1M: 0.025 },\r\n 'gemini-2.0-flash-lite': { inputPer1M: 0.075, outputPer1M: 0.3, cachedInputPer1M: 0.01875 },\r\n 'gemini-2.0-pro': { inputPer1M: 1.25, outputPer1M: 5.0, cachedInputPer1M: 0.3125 },\r\n\r\n // --- Google Gemini (Legacy & Backward Compatibility) ---\r\n 'gemini-1.5-pro': { inputPer1M: 1.25, outputPer1M: 5.0, cachedInputPer1M: 0.3125 },\r\n 'gemini-1.5-flash': { inputPer1M: 0.075, outputPer1M: 0.3, cachedInputPer1M: 0.01875 },\r\n 'gemini-1.5-flash-8b': { inputPer1M: 0.0375, outputPer1M: 0.15, cachedInputPer1M: 0.009375 },\r\n 'gemini-1.0-pro': { inputPer1M: 0.5, outputPer1M: 1.5 },\r\n\r\n // --- xAI Grok ---\r\n 'grok-4.6': { inputPer1M: 3.0, outputPer1M: 15.0 },\r\n 'grok-3': { inputPer1M: 3.0, outputPer1M: 15.0 },\r\n 'grok-3-mini': { inputPer1M: 0.3, outputPer1M: 1.5 },\r\n 'grok-2': { inputPer1M: 2.0, outputPer1M: 10.0 },\r\n 'grok-2-vision': { inputPer1M: 2.0, outputPer1M: 10.0 },\r\n 'grok-beta': { inputPer1M: 5.0, outputPer1M: 15.0 },\r\n\r\n // --- Mistral ---\r\n 'mistral-large-3': { inputPer1M: 2.0, outputPer1M: 6.0 },\r\n 'mistral-large-latest': { inputPer1M: 2.0, outputPer1M: 6.0 },\r\n 'mistral-large-2411': { inputPer1M: 2.0, outputPer1M: 6.0 },\r\n 'codestral-latest': { inputPer1M: 0.3, outputPer1M: 0.9 },\r\n 'mistral-medium-latest': { inputPer1M: 2.7, outputPer1M: 8.1 },\r\n 'mistral-medium-3-5': { inputPer1M: 2.0, outputPer1M: 6.0, cachedInputPer1M: 0.4 },\r\n 'mistral-medium-2604': { inputPer1M: 2.0, outputPer1M: 6.0, cachedInputPer1M: 0.4 },\r\n 'magistral-small-latest': { inputPer1M: 0.5, outputPer1M: 1.5, cachedInputPer1M: 0.1 },\r\n 'magistral-medium-latest': { inputPer1M: 2.0, outputPer1M: 6.0, cachedInputPer1M: 0.4 },\r\n 'mistral-small-latest': { inputPer1M: 0.2, outputPer1M: 0.6 },\r\n 'mistral-small-2603': { inputPer1M: 0.2, outputPer1M: 0.6, cachedInputPer1M: 0.05 },\r\n 'mistral-vibe-cli-fast': { inputPer1M: 0.2, outputPer1M: 0.6, cachedInputPer1M: 0.05 },\r\n 'mistral-vibe-cli-latest': { inputPer1M: 0.2, outputPer1M: 0.6, cachedInputPer1M: 0.05 },\r\n 'codestral-2508': { inputPer1M: 0.3, outputPer1M: 0.9, cachedInputPer1M: 0.08 },\r\n 'codestral-embed': { inputPer1M: 0.1, outputPer1M: 0.0 },\r\n 'mistral-embed-2312': { inputPer1M: 0.1, outputPer1M: 0.0 },\r\n 'zai-glm-5-2': { inputPer1M: 0.6, outputPer1M: 2.2, cachedInputPer1M: 0.15 },\r\n 'glm-5-2': { inputPer1M: 0.6, outputPer1M: 2.2, cachedInputPer1M: 0.15 },\r\n 'labs-leanstral-1-5': { inputPer1M: 0.2, outputPer1M: 0.6, cachedInputPer1M: 0.05 },\r\n 'ministral-8b-latest': { inputPer1M: 0.1, outputPer1M: 0.1 },\r\n 'ministral-3b-latest': { inputPer1M: 0.04, outputPer1M: 0.04 },\r\n 'open-mistral-7b': { inputPer1M: 0.2, outputPer1M: 0.2 },\r\n 'open-mixtral-8x7b': { inputPer1M: 0.7, outputPer1M: 0.7 },\r\n 'open-mixtral-8x22b': { inputPer1M: 2.0, outputPer1M: 6.0 },\r\n\r\n // --- Groq & Meta Llama LPUs ---\r\n 'llama-3.3-70b-versatile': { inputPer1M: 0.59, outputPer1M: 0.79 },\r\n 'llama-3.1-405b': { inputPer1M: 3.0, outputPer1M: 3.0 },\r\n 'llama-3.1-70b-versatile': { inputPer1M: 0.59, outputPer1M: 0.79 },\r\n 'llama-3.1-8b-instant': { inputPer1M: 0.05, outputPer1M: 0.08 },\r\n 'llama-3.2-1b-preview': { inputPer1M: 0.04, outputPer1M: 0.04 },\r\n 'llama-3.2-3b-preview': { inputPer1M: 0.06, outputPer1M: 0.06 },\r\n 'llama-3.2-11b-vision': { inputPer1M: 0.18, outputPer1M: 0.18 },\r\n 'llama-3.2-90b-vision': { inputPer1M: 0.90, outputPer1M: 0.90 },\r\n 'deepseek-r1-distill-llama-70b': { inputPer1M: 0.75, outputPer1M: 0.99 },\r\n 'deepseek-r1-distill-qwen-32b': { inputPer1M: 0.49, outputPer1M: 0.49 },\r\n 'qwen-2.5-32b': { inputPer1M: 0.29, outputPer1M: 0.39 },\r\n 'qwen-2.5-72b': { inputPer1M: 0.35, outputPer1M: 0.40 },\r\n 'mixtral-8x7b-32768': { inputPer1M: 0.24, outputPer1M: 0.24 },\r\n 'gemma2-9b-it': { inputPer1M: 0.20, outputPer1M: 0.20 },\r\n\r\n // --- DeepSeek ---\r\n 'deepseek-v4-pro': { inputPer1M: 0.66, outputPer1M: 1.98, cachedInputPer1M: 0.15 },\r\n 'deepseek-v4.1-flash': { inputPer1M: 0.20, outputPer1M: 0.60, cachedInputPer1M: 0.05 },\r\n 'deepseek-v4-flash': { inputPer1M: 0.22, outputPer1M: 0.66, cachedInputPer1M: 0.05 },\r\n 'deepseek-v3': { inputPer1M: 0.14, outputPer1M: 0.28, cachedInputPer1M: 0.014 },\r\n 'deepseek-chat': { inputPer1M: 0.14, outputPer1M: 0.28, cachedInputPer1M: 0.014 },\r\n 'deepseek-r1': { inputPer1M: 0.55, outputPer1M: 2.19, cachedInputPer1M: 0.14 },\r\n 'deepseek-reasoner': { inputPer1M: 0.55, outputPer1M: 2.19, cachedInputPer1M: 0.14 },\r\n\r\n // --- Gateway, Inception & InclusionAI Models ---\r\n 'mercury-2.5': { inputPer1M: 0.25, outputPer1M: 0.75, cachedInputPer1M: 0.05 },\r\n 'mercury-2': { inputPer1M: 0.25, outputPer1M: 0.75, cachedInputPer1M: 0.05 },\r\n 'ling-3.0-flash-sante': { inputPer1M: 0.15, outputPer1M: 0.45, cachedInputPer1M: 0.03 },\r\n 'ling-3.0-flash': { inputPer1M: 0.15, outputPer1M: 0.45, cachedInputPer1M: 0.03 },\r\n\r\n // --- Cohere ---\r\n 'command-r-plus': { inputPer1M: 2.5, outputPer1M: 10.0 },\r\n 'command-r': { inputPer1M: 0.15, outputPer1M: 0.6 },\r\n 'command': { inputPer1M: 1.0, outputPer1M: 2.0 },\r\n 'command-light': { inputPer1M: 0.3, outputPer1M: 0.6 },\r\n 'embed-english-v3.0': { inputPer1M: 0.10, outputPer1M: 0.0 },\r\n\r\n // --- Perplexity ---\r\n 'sonar': { inputPer1M: 1.0, outputPer1M: 1.0 },\r\n 'sonar-pro': { inputPer1M: 3.0, outputPer1M: 15.0 },\r\n 'sonar-reasoning': { inputPer1M: 1.0, outputPer1M: 5.0 },\r\n 'sonar-reasoning-pro': { inputPer1M: 2.0, outputPer1M: 8.0 },\r\n};\r\n\r\n/**\r\n * Common model alias map to normalize nicknames, shorthands, and legacy IDs\r\n */\r\nexport const MODEL_ALIASES: Record<string, string> = {\r\n // OpenAI Shorthands & Aliases\r\n 'gpt4': 'gpt-4',\r\n 'gpt4o': 'gpt-4o',\r\n 'gpt-4-preview': 'gpt-4-turbo',\r\n 'gpt-4-0125-preview': 'gpt-4-turbo',\r\n 'gpt-4-1106-preview': 'gpt-4-turbo',\r\n 'gpt-3.5': 'gpt-3.5-turbo',\r\n 'gpt-3.5-turbo-0125': 'gpt-3.5-turbo',\r\n 'gpt-3.5-turbo-1106': 'gpt-3.5-turbo',\r\n 'gpt-3.5-turbo-16k-0613': 'gpt-3.5-turbo-16k',\r\n\r\n // Anthropic Shorthands\r\n 'sonnet': 'claude-3-5-sonnet',\r\n 'sonnet-3.7': 'claude-3-7-sonnet',\r\n 'sonnet-3.5': 'claude-3-5-sonnet',\r\n 'haiku': 'claude-3-5-haiku',\r\n 'haiku-3.5': 'claude-3-5-haiku',\r\n 'opus': 'claude-3-opus',\r\n 'claude-2': 'claude-2.0',\r\n 'claude-instant': 'claude-instant-1.2',\r\n\r\n // DeepSeek Shorthands\r\n 'r1': 'deepseek-r1',\r\n 'v3': 'deepseek-v3',\r\n\r\n // Gemini Shorthands\r\n 'flash': 'gemini-2.0-flash',\r\n 'pro': 'gemini-1.5-pro',\r\n\r\n // Meta / Groq Shorthands\r\n 'llama-3.3-70b': 'llama-3.3-70b-versatile',\r\n 'llama-3.1-70b': 'llama-3.1-70b-versatile',\r\n 'llama-3.1-8b': 'llama-3.1-8b-instant',\r\n 'llama-3-70b': 'llama-3.1-70b-versatile',\r\n 'llama-3-8b': 'llama-3.1-8b-instant',\r\n\r\n // Mistral Shorthands\r\n 'codestral': 'codestral-latest',\r\n 'mistral-large': 'mistral-large-latest',\r\n 'mistral-small': 'mistral-small-latest',\r\n 'magistral': 'magistral-small-latest',\r\n 'magistral-small': 'magistral-small-latest',\r\n 'magistral-medium': 'magistral-medium-latest',\r\n 'mistral-3.5': 'mistral-medium-3-5',\r\n 'mistral-medium-3.5': 'mistral-medium-3-5',\r\n 'gpt-image-2.5': 'gpt-image-2.5-flare',\r\n 'gpt-image-sunburst': 'gpt-image-2.5-sunburst',\r\n 'gpt-image-flare': 'gpt-image-2.5-flare',\r\n};\r\n\r\n/**\r\n * Dynamic in-memory registry allowing runtime custom price registration\r\n */\r\nconst customPricingRegistry: Record<string, ModelPricingRates> = {};\r\n\r\n/**\r\n * Normalize model identifier to match pricing table keys:\r\n * - Strips AWS Bedrock prefixes (e.g. 'anthropic.claude-3-5-sonnet-20241022-v2:0' -> 'claude-3-5-sonnet')\r\n * - Strips provider prefixes (e.g. 'openai/gpt-4o' -> 'gpt-4o', 'deepseek/deepseek-r1' -> 'deepseek-r1')\r\n * - Strips date suffixes (e.g. '-20240307', '-20250219')\r\n * - Resolves shorthands and aliases\r\n */\r\nexport function normalizeModelKey(rawModel: string): string {\r\n if (!rawModel) return 'unknown';\r\n\r\n let model = rawModel.toLowerCase().trim();\r\n\r\n // Strip AWS Bedrock model prefix (e.g. 'us.anthropic.claude-3-5-sonnet...', 'meta.llama3-...')\r\n model = model.replace(/^[a-z0-9_-]+\\.(anthropic|meta|amazon|cohere|mistral|ai21)\\./i, '');\r\n model = model.replace(/^(anthropic|meta|amazon|cohere|mistral|ai21)\\./i, '');\r\n\r\n // Strip AWS Bedrock version suffix (e.g. '-v1:0', '-v2:0', ':0')\r\n model = model.replace(/-v\\d+(:\\d+)?$/, '');\r\n model = model.replace(/:\\d+$/, '');\r\n\r\n // Strip provider prefix if present (e.g. 'openai/gpt-4o' -> 'gpt-4o', 'meta-llama/llama-3.3-70b-instruct' -> 'llama-3.3-70b-instruct')\r\n if (model.includes('/')) {\r\n model = model.split('/').slice(1).join('/');\r\n }\r\n\r\n // Remove trailing version/mode tags (e.g. ':latest', ':free', ':beta')\r\n model = model.replace(/:(latest|free|beta)$/, '');\r\n\r\n // Remove date suffixes like -20240307 or -20250219 or -2024-08-06\r\n model = model.replace(/-\\d{8}$/, '');\r\n model = model.replace(/-\\d{4}-\\d{2}-\\d{2}$/, '');\r\n\r\n // Normalize Bedrock Meta format (e.g. llama3-1-70b -> llama-3.1-70b)\r\n model = model.replace(/llama(\\d+)-(\\d+)-/g, 'llama-$1.$2-');\r\n model = model.replace(/llama(\\d+)\\.(\\d+)-/g, 'llama-$1.$2-');\r\n\r\n // Check aliases before fine-tuning\r\n if (MODEL_ALIASES[model]) {\r\n return MODEL_ALIASES[model];\r\n }\r\n\r\n // Remove common modifier suffixes if not directly matching table\r\n if (!MODEL_PRICING_TABLE[model]) {\r\n const withoutInstruct = model.replace(/-(instruct|chat|preview)$/, '');\r\n if (MODEL_PRICING_TABLE[withoutInstruct]) {\r\n return withoutInstruct;\r\n }\r\n if (MODEL_ALIASES[withoutInstruct]) {\r\n return MODEL_ALIASES[withoutInstruct];\r\n }\r\n }\r\n\r\n return model;\r\n}\r\n\r\n/**\r\n * Retrieve pricing rates for a given model\r\n */\r\nexport function getModelPricing(modelName: string): ModelPricingRates {\r\n const normalized = normalizeModelKey(modelName);\r\n\r\n // Check custom registry first\r\n if (customPricingRegistry[normalized]) {\r\n return customPricingRegistry[normalized];\r\n }\r\n if (customPricingRegistry[modelName]) {\r\n return customPricingRegistry[modelName];\r\n }\r\n\r\n // Check dynamic synced manifest cache\r\n const dynamicRate = getDynamicRate(modelName) || getDynamicRate(normalized);\r\n if (dynamicRate) {\r\n return dynamicRate;\r\n }\r\n\r\n // Check built-in table with normalized key\r\n if (MODEL_PRICING_TABLE[normalized]) {\r\n return MODEL_PRICING_TABLE[normalized];\r\n }\r\n // Check built-in table with direct key\r\n if (MODEL_PRICING_TABLE[modelName]) {\r\n return MODEL_PRICING_TABLE[modelName];\r\n }\r\n\r\n // Check alias table fallback\r\n const alias = MODEL_ALIASES[modelName.toLowerCase().trim()];\r\n if (alias) {\r\n const dynamicAlias = getDynamicRate(alias);\r\n if (dynamicAlias) return dynamicAlias;\r\n if (MODEL_PRICING_TABLE[alias]) {\r\n return MODEL_PRICING_TABLE[alias];\r\n }\r\n }\r\n\r\n // Fallback defaults for unknown models (conservative estimates: $1.00 in, $3.00 out)\r\n return {\r\n inputPer1M: 1.0,\r\n outputPer1M: 3.0,\r\n cachedInputPer1M: 0.5,\r\n };\r\n}\r\n\r\n/**\r\n * Register or override pricing rates for a custom model\r\n */\r\nexport function registerModelPricing(modelName: string, rates: ModelPricingRates): void {\r\n const normalized = normalizeModelKey(modelName);\r\n customPricingRegistry[normalized] = rates;\r\n customPricingRegistry[modelName] = rates;\r\n}\r\n","import fs from 'fs';\r\nimport path from 'path';\r\nimport readline from 'readline';\r\n\r\nexport interface RouteAuditFinding {\r\n file: string;\r\n relativePath: string;\r\n status: 'protected' | 'unmetered' | 'unprotected_direct';\r\n line: number;\r\n rawSnippet: string;\r\n suggestedFix?: string;\r\n modelOrProvider?: string;\r\n details: string;\r\n}\r\n\r\nexport interface AuditOptions {\r\n dir?: string;\r\n fix?: boolean;\r\n ci?: boolean;\r\n json?: boolean;\r\n silent?: boolean;\r\n}\r\n\r\nexport interface AuditSummary {\r\n scannedFiles: number;\r\n aiRoutesCount: number;\r\n protectedCount: number;\r\n unmeteredCount: number;\r\n scanTimeMs: number;\r\n findings: RouteAuditFinding[];\r\n}\r\n\r\nconst IGNORED_DIRS = new Set([\r\n 'node_modules',\r\n '.next',\r\n '.git',\r\n 'dist',\r\n 'build',\r\n '.turbo',\r\n 'coverage',\r\n '.cache',\r\n '.vercel',\r\n 'tests',\r\n 'test',\r\n '__tests__',\r\n 'examples',\r\n 'fixtures',\r\n]);\r\n\r\nconst EXTENSIONS = new Set(['.ts', '.tsx', '.js', '.jsx', '.mjs']);\r\n\r\n/**\r\n * Discovers API and server route files in the project.\r\n */\r\nexport function findRouteFiles(rootDir: string): string[] {\r\n const targetSubdirs = [\r\n path.join('app', 'api'),\r\n path.join('src', 'app', 'api'),\r\n path.join('pages', 'api'),\r\n path.join('src', 'pages', 'api'),\r\n 'routes',\r\n path.join('src', 'routes'),\r\n path.join('server', 'api'),\r\n path.join('server', 'routes'),\r\n ];\r\n\r\n const foundFiles: string[] = [];\r\n\r\n // Check designated route directories first\r\n let searchedDesignated = false;\r\n for (const rel of targetSubdirs) {\r\n const full = path.join(rootDir, rel);\r\n if (fs.existsSync(full)) {\r\n searchedDesignated = true;\r\n scanDirRecursive(full, foundFiles);\r\n }\r\n }\r\n\r\n // If no designated route folders exist or very few files, scan app/ and src/app/\r\n if (foundFiles.length === 0) {\r\n const appDir = fs.existsSync(path.join(rootDir, 'app'))\r\n ? path.join(rootDir, 'app')\r\n : fs.existsSync(path.join(rootDir, 'src', 'app'))\r\n ? path.join(rootDir, 'src', 'app')\r\n : rootDir;\r\n\r\n scanDirRecursive(appDir, foundFiles);\r\n }\r\n\r\n return Array.from(new Set(foundFiles));\r\n}\r\n\r\nfunction scanDirRecursive(currentDir: string, results: string[]): void {\r\n try {\r\n const entries = fs.readdirSync(currentDir, { withFileTypes: true });\r\n for (const entry of entries) {\r\n if (entry.isDirectory()) {\r\n if (!IGNORED_DIRS.has(entry.name)) {\r\n scanDirRecursive(path.join(currentDir, entry.name), results);\r\n }\r\n } else if (entry.isFile()) {\r\n const ext = path.extname(entry.name);\r\n if (EXTENSIONS.has(ext)) {\r\n // Exclude spec/test files\r\n if (!entry.name.includes('.test.') && !entry.name.includes('.spec.')) {\r\n results.push(path.join(currentDir, entry.name));\r\n }\r\n }\r\n }\r\n }\r\n } catch {\r\n // Gracefully ignore inaccessible dirs\r\n }\r\n}\r\n\r\n/**\r\n * Audits a single file for AI SDK and LLM usage.\r\n */\r\nexport function auditFile(filePath: string, rootDir: string): RouteAuditFinding[] {\r\n const relativePath = path.relative(rootDir, filePath).replace(/\\\\/g, '/');\r\n let content = '';\r\n try {\r\n content = fs.readFileSync(filePath, 'utf-8');\r\n } catch {\r\n return [];\r\n }\r\n\r\n // Fast pre-filter: Does this file even reference AI libraries?\r\n const hasAiKeywords =\r\n content.includes('streamText') ||\r\n content.includes('generateText') ||\r\n content.includes('streamObject') ||\r\n content.includes('generateObject') ||\r\n content.includes('OpenAI') ||\r\n content.includes('Anthropic') ||\r\n content.includes('vibezcheck');\r\n\r\n if (!hasAiKeywords) {\r\n return [];\r\n }\r\n\r\n const lines = content.split(/\\r?\\n/);\r\n const findings: RouteAuditFinding[] = [];\r\n\r\n // Check 1: Vercel AI SDK usage (streamText, generateText, etc.)\r\n const aiSdkRegex = /\\b(streamText|generateText|streamObject|generateObject)\\s*\\(\\s*\\{/g;\r\n let match: RegExpExecArray | null;\r\n\r\n while ((match = aiSdkRegex.exec(content)) !== null) {\r\n const matchIndex = match.index;\r\n const lineNumber = content.substring(0, matchIndex).split(/\\r?\\n/).length;\r\n\r\n // Scan forward a few lines (up to 25 lines) to inspect the `model:` argument\r\n const snippetLines = lines.slice(lineNumber - 1, lineNumber + 25);\r\n const snippet = snippetLines.join('\\n');\r\n\r\n // Look for model:\r\n const modelLineMatch = snippet.match(/model\\s*:\\s*([^,\\n}]+)/);\r\n if (modelLineMatch) {\r\n const modelExpr = modelLineMatch[1].trim();\r\n const modelLineOffset = snippetLines.findIndex((l) => l.includes('model:'));\r\n const actualLine = lineNumber + (modelLineOffset >= 0 ? modelLineOffset : 0);\r\n const rawSnippet = lines[actualLine - 1] || modelLineMatch[0];\r\n\r\n const isProtected =\r\n modelExpr.includes('vibezcheck(') ||\r\n modelExpr.includes('session.model(') ||\r\n modelExpr.includes('vz.model(');\r\n\r\n if (isProtected) {\r\n findings.push({\r\n file: filePath,\r\n relativePath,\r\n status: 'protected',\r\n line: actualLine,\r\n rawSnippet,\r\n modelOrProvider: modelExpr,\r\n details: 'Metered with 0ms added latency and $0.50 safety fuse ceiling',\r\n });\r\n } else {\r\n // Raw unmetered AI call\r\n const suggestedFix = `model: vibezcheck(${modelExpr}),`;\r\n findings.push({\r\n file: filePath,\r\n relativePath,\r\n status: 'unmetered',\r\n line: actualLine,\r\n rawSnippet,\r\n suggestedFix,\r\n modelOrProvider: modelExpr,\r\n details: 'Direct provider call without cost limit or token metering',\r\n });\r\n }\r\n }\r\n }\r\n\r\n // Check 2: Direct raw client instantiation (new OpenAI(), new Anthropic())\r\n for (let i = 0; i < lines.length; i++) {\r\n const line = lines[i];\r\n if (\r\n (line.includes('new OpenAI(') || line.includes('new Anthropic(')) &&\r\n !content.includes('vibezcheck') &&\r\n !content.includes('wrapStream') &&\r\n !content.includes('trackUsage')\r\n ) {\r\n findings.push({\r\n file: filePath,\r\n relativePath,\r\n status: 'unprotected_direct',\r\n line: i + 1,\r\n rawSnippet: line.trim(),\r\n details: 'Direct client instance without circuit breaker fuse',\r\n });\r\n break; // One direct warning per file is sufficient\r\n }\r\n }\r\n\r\n return findings;\r\n}\r\n\r\n/**\r\n * Runs the audit across the project.\r\n */\r\nexport async function runAudit(options: AuditOptions = {}): Promise<AuditSummary> {\r\n const startTime = Date.now();\r\n const rootDir = options.dir ? path.resolve(options.dir) : process.cwd();\r\n\r\n const files = findRouteFiles(rootDir);\r\n const allFindings: RouteAuditFinding[] = [];\r\n\r\n for (const file of files) {\r\n const findings = auditFile(file, rootDir);\r\n allFindings.push(...findings);\r\n }\r\n\r\n const protectedCount = allFindings.filter((f) => f.status === 'protected').length;\r\n const unmeteredCount = allFindings.filter(\r\n (f) => f.status === 'unmetered' || f.status === 'unprotected_direct'\r\n ).length;\r\n\r\n const summary: AuditSummary = {\r\n scannedFiles: files.length,\r\n aiRoutesCount: allFindings.length,\r\n protectedCount,\r\n unmeteredCount,\r\n scanTimeMs: Date.now() - startTime,\r\n findings: allFindings,\r\n };\r\n\r\n return summary;\r\n}\r\n\r\n/**\r\n * Safely applies the 1-line vibezcheck wrap to an unmetered file.\r\n * Creates a `.bak` backup copy first.\r\n */\r\nexport function applyFixToFile(filePath: string): boolean {\r\n try {\r\n const content = fs.readFileSync(filePath, 'utf-8');\r\n\r\n // Create backup\r\n fs.writeFileSync(`${filePath}.bak`, content, 'utf-8');\r\n\r\n let updated = content;\r\n\r\n // 1. Ensure import exists\r\n if (!updated.includes(\"from 'vibezcheck'\") && !updated.includes('from \"vibezcheck\"')) {\r\n // Find the last import statement or place at top\r\n const importRegex = /^import\\s+.*?;\\s*$/gm;\r\n let lastImportMatch: RegExpExecArray | null = null;\r\n let match: RegExpExecArray | null;\r\n while ((match = importRegex.exec(updated)) !== null) {\r\n lastImportMatch = match;\r\n }\r\n\r\n const importStatement = \"import { vibezcheck } from 'vibezcheck';\\n\";\r\n if (lastImportMatch) {\r\n const insertPos = lastImportMatch.index + lastImportMatch[0].length;\r\n updated = updated.slice(0, insertPos) + '\\n' + importStatement + updated.slice(insertPos);\r\n } else {\r\n updated = importStatement + updated;\r\n }\r\n }\r\n\r\n // 2. Wrap model: <expr> with vibezcheck(<expr>)\r\n // Regex matches: model:\\s*([a-zA-Z0-9_$]+(?:\\([^)]*\\)|'[^']*'|\"[^\"]*\"))\r\n updated = updated.replace(\r\n /model\\s*:\\s*(?!vibezcheck\\()([a-zA-Z0-9_$]+(?:\\([^)]*\\)|'[^']*'|\"[^\"]*\"))/g,\r\n 'model: vibezcheck($1)'\r\n );\r\n\r\n fs.writeFileSync(filePath, updated, 'utf-8');\r\n return true;\r\n } catch {\r\n return false;\r\n }\r\n}\r\n\r\n/**\r\n * Renders the kind, minimalist terminal output.\r\n */\r\nexport async function displayAuditReport(\r\n summary: AuditSummary,\r\n options: AuditOptions = {}\r\n): Promise<void> {\r\n // If JSON mode requested, output raw JSON and return\r\n if (options.json) {\r\n console.log(JSON.stringify(summary, null, 2));\r\n if (options.ci && summary.unmeteredCount > 0) {\r\n process.exit(1);\r\n }\r\n return;\r\n }\r\n\r\n console.log(`\\n\\x1b[38;2;212;255;50m✦\\x1b[0m \\x1b[1mvibezcheck audit\\x1b[0m \\x1b[90m(${summary.scanTimeMs}ms)\\x1b[0m\\n`);\r\n\r\n // Case 1: No AI routes detected\r\n if (summary.aiRoutesCount === 0) {\r\n console.log(` \\x1b[90mNo AI routes detected across ${summary.scannedFiles} files.\\x1b[0m`);\r\n console.log(` Ready to build your first metered route? Run: \\x1b[36mnpx vibezcheck init\\x1b[0m\\n`);\r\n return;\r\n }\r\n\r\n // Case 2: All routes protected (The Calm State)\r\n if (summary.unmeteredCount === 0) {\r\n const message =\r\n summary.protectedCount === 1\r\n ? '✓ The AI route is metered with a $0.50 safety fuse.'\r\n : `✓ All ${summary.protectedCount} AI routes are metered with $0.50 safety fuses.`;\r\n console.log(` \\x1b[32m${message}\\x1b[0m`);\r\n console.log(` \\x1b[90mYour wallet is protected. You're good to ship.\\x1b[0m\\n`);\r\n return;\r\n }\r\n\r\n // Case 3: Unmetered routes found (The Kind Companion)\r\n const unmeteredFindings = summary.findings.filter((f) => f.status !== 'protected');\r\n const countWord = unmeteredFindings.length === 1 ? 'route' : 'routes';\r\n\r\n console.log(\r\n ` We noticed \\x1b[33m${unmeteredFindings.length} ${countWord}\\x1b[0m calling AI providers directly without a safety fuse:\\n`\r\n );\r\n\r\n for (const finding of unmeteredFindings) {\r\n console.log(` \\x1b[1m→ ${finding.relativePath}:${finding.line}\\x1b[0m`);\r\n console.log(` \\x1b[90mCurrent:\\x1b[0m \\x1b[31m${finding.rawSnippet.trim()}\\x1b[0m`);\r\n if (finding.suggestedFix) {\r\n console.log(` \\x1b[90m1-Line Fix:\\x1b[0m \\x1b[32m${finding.suggestedFix}\\x1b[0m`);\r\n }\r\n console.log('');\r\n }\r\n\r\n console.log(` \\x1b[1mWhy this matters:\\x1b[0m`);\r\n console.log(` \\x1b[90mUnmetered routes bill directly to your credit card without runaway limits.`);\r\n console.log(` Wrapping them adds 0ms token metering, $0.50 runaway fuses, and prompt cache discounts.\\x1b[0m\\n`);\r\n\r\n // Auto-fix handling\r\n if (options.fix) {\r\n let fixedCount = 0;\r\n const uniqueFiles = Array.from(new Set(unmeteredFindings.map((f) => f.file)));\r\n for (const file of uniqueFiles) {\r\n if (applyFixToFile(file)) {\r\n fixedCount++;\r\n const rel = path.relative(process.cwd(), file).replace(/\\\\/g, '/');\r\n console.log(` \\x1b[32m✓ Safely wrapped ${rel}\\x1b[0m \\x1b[90m(backup saved as .bak)\\x1b[0m`);\r\n }\r\n }\r\n console.log(`\\n \\x1b[32m\\x1b[1m🎉 All done!\\x1b[0m \\x1b[90mRun tests or build to verify.\\x1b[0m\\n`);\r\n return;\r\n }\r\n\r\n // Interactive prompt if TTY and not CI\r\n if (!options.ci && process.stdin.isTTY) {\r\n const rl = readline.createInterface({\r\n input: process.stdin,\r\n output: process.stdout,\r\n });\r\n\r\n const answer = await new Promise<string>((resolve) => {\r\n rl.question(\r\n ` \\x1b[38;2;212;255;50m⚡ Would you like VibezCheck to safely wrap these routes for you? (y/N): \\x1b[0m`,\r\n (ans) => {\r\n rl.close();\r\n resolve(ans.trim().toLowerCase());\r\n }\r\n );\r\n });\r\n\r\n if (answer === 'y' || answer === 'yes') {\r\n const uniqueFiles = Array.from(new Set(unmeteredFindings.map((f) => f.file)));\r\n for (const file of uniqueFiles) {\r\n if (applyFixToFile(file)) {\r\n const rel = path.relative(process.cwd(), file).replace(/\\\\/g, '/');\r\n console.log(` \\x1b[32m✓ Safely wrapped ${rel}\\x1b[0m \\x1b[90m(backup saved as .bak)\\x1b[0m`);\r\n }\r\n }\r\n console.log(`\\n \\x1b[32m\\x1b[1m🎉 All done!\\x1b[0m \\x1b[90mRun tests or build to verify.\\x1b[0m\\n`);\r\n return;\r\n }\r\n }\r\n\r\n // If CI mode and unmetered found, exit with non-zero\r\n if (options.ci) {\r\n console.log(` \\x1b[31m✖ CI check failed: ${summary.unmeteredCount} unmetered route(s) found.\\x1b[0m\\n`);\r\n process.exit(1);\r\n }\r\n}\r\n","import fs from 'fs';\nimport path from 'path';\nimport readline from 'readline';\n\nexport interface ExampleMeta {\n id: string;\n name: string;\n type: 'project' | 'script';\n description: string;\n framework: string;\n path: string;\n tags: string[];\n}\n\nexport const AVAILABLE_EXAMPLES: ExampleMeta[] = [\n {\n id: 'nextjs-saas-starter',\n name: 'Next.js 15 AI SaaS Starter',\n type: 'project',\n description: 'Production B2B SaaS with customer wallets, <VibezReceipt />, margins & 2026 models',\n framework: 'Next.js 15 (App Router)',\n path: 'nextjs-saas-starter',\n tags: ['Next.js 15', 'React 19', 'Full SaaS'],\n },\n {\n id: 'nextjs-app-router-openai',\n name: 'Next.js App Router OpenAI Minimal',\n type: 'project',\n description: 'Minimal 1-line streamText model wrapper with @ai-sdk/openai, auto-metering & safety fuse',\n framework: 'Next.js 15 (App Router)',\n path: 'nextjs-app-router-openai',\n tags: ['Next.js 15', 'OpenAI', '1-Line Wrapper'],\n },\n {\n id: '01-local-cost-meter',\n name: 'Local Token & Cost Calculator',\n type: 'script',\n description: 'Free standalone inference cost calculation and token aggregation with zero dependencies',\n framework: 'TypeScript / Node.js',\n path: '01-local-cost-meter.ts',\n tags: ['Zero Config', 'Free', 'Local'],\n },\n {\n id: '02-vercel-ai-sdk',\n name: 'AI SDK Multi-Tenant Route Wrapper',\n type: 'script',\n description: 'B2B multi-tenant model wrapper with organization metadata, 30% profit margin & runaway fuse',\n framework: 'AI SDK / TypeScript',\n path: '02-vercel-ai-sdk.ts',\n tags: ['B2B', 'Multi-Tenant', 'Margins'],\n },\n {\n id: '03-native-openai-stream',\n name: 'Native OpenAI Stream Tracking',\n type: 'script',\n description: 'Wrap native openai.chat.completions.create streams with 0ms added latency',\n framework: 'OpenAI SDK',\n path: '03-native-openai-stream.ts',\n tags: ['Native SDK', '0ms Latency'],\n },\n {\n id: '04-claude-thinking',\n name: 'Claude 3.7 Sonnet Extended Thinking',\n type: 'script',\n description: 'Track reasoning and thinking token streams with Anthropic SDK',\n framework: 'Anthropic SDK',\n path: '04-claude-thinking.ts',\n tags: ['Reasoning', 'Claude 3.7', 'Thinking'],\n },\n {\n id: '05-reasoning-agent-stream',\n name: 'Autonomous Reasoning Agent Loop',\n type: 'script',\n description: 'Multi-step agent loop handling reasoning deltas, prompt caching & runaway circuit breaker',\n framework: 'AI SDK / Agents',\n path: '05-reasoning-agent-stream.ts',\n tags: ['Agents', 'Reasoning Deltas', 'Safety Fuse'],\n },\n];\n\n/**\n * Locate the examples directory across local workspace and installed package paths\n */\nexport function findExamplesDir(): string {\n const candidates = [\n path.resolve(__dirname, '../../examples'),\n path.resolve(__dirname, '../examples'),\n path.resolve(__dirname, '../../../examples'),\n path.resolve(process.cwd(), 'examples'),\n path.resolve(process.cwd(), 'node_modules/vibezcheck/examples'),\n ];\n\n for (const c of candidates) {\n if (fs.existsSync(c)) {\n return c;\n }\n }\n\n return path.resolve(__dirname, '../../examples');\n}\n\n/**\n * Copy directory recursively, skipping node_modules and transient folders\n */\nexport function copyDir(src: string, dest: string): void {\n fs.mkdirSync(dest, { recursive: true });\n const entries = fs.readdirSync(src, { withFileTypes: true });\n\n for (const entry of entries) {\n const srcPath = path.join(src, entry.name);\n const destPath = path.join(dest, entry.name);\n\n if (entry.isDirectory()) {\n if (['node_modules', '.next', '.git', 'dist', 'coverage', '.turbo'].includes(entry.name)) {\n continue;\n }\n copyDir(srcPath, destPath);\n } else {\n if (entry.name === '.env.local' || entry.name.endsWith('.log')) {\n continue;\n }\n fs.copyFileSync(srcPath, destPath);\n }\n }\n}\n\nasync function prompt(question: string, defaultVal: string = ''): Promise<string> {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n return new Promise((resolve) => {\n const promptText = defaultVal\n ? `\\x1b[32m?\\x1b[0m \\x1b[1m${question}\\x1b[0m \\x1b[90m(${defaultVal})\\x1b[0m: `\n : `\\x1b[32m?\\x1b[0m \\x1b[1m${question}\\x1b[0m: `;\n\n rl.question(promptText, (answer) => {\n rl.close();\n resolve(answer.trim() || defaultVal);\n });\n });\n}\n\n/**\n * Display formatted catalogue of all available examples\n */\nexport function listExamples(): void {\n console.log('\\x1b[1m✦ VibezCheck Official Examples & Starters\\x1b[0m\\n');\n\n AVAILABLE_EXAMPLES.forEach((ex, index) => {\n const num = `[${index + 1}]`.padEnd(4);\n const typeTag = ex.type === 'project' \n ? '\\x1b[42m\\x1b[30m PROJECT \\x1b[0m' \n : '\\x1b[44m\\x1b[37m SCRIPT \\x1b[0m';\n \n console.log(`${num} ${typeTag} \\x1b[1m${ex.name}\\x1b[0m \\x1b[90m(${ex.id})\\x1b[0m`);\n console.log(` \\x1b[90mFramework:\\x1b[0m ${ex.framework}`);\n console.log(` \\x1b[90mDescription:\\x1b[0m ${ex.description}`);\n console.log(` \\x1b[90mCommand:\\x1b[0m \\x1b[36mnpx vibezcheck example ${ex.id}\\x1b[0m\\n`);\n });\n}\n\n/**\n * Scaffold selected example into target directory\n */\nexport async function scaffoldExample(exampleInput?: string, targetDirInput?: string): Promise<boolean> {\n const examplesBase = findExamplesDir();\n\n let selected = AVAILABLE_EXAMPLES.find(\n (e) => e.id.toLowerCase() === exampleInput?.toLowerCase()\n );\n\n // Check if numeric selection was entered (e.g. \"1\")\n if (!selected && exampleInput && !isNaN(Number(exampleInput))) {\n const idx = Number(exampleInput) - 1;\n if (idx >= 0 && idx < AVAILABLE_EXAMPLES.length) {\n selected = AVAILABLE_EXAMPLES[idx];\n }\n }\n\n // Interactive selection if not found or not provided\n if (!selected) {\n listExamples();\n const choice = await prompt('Select an example number (1-7) or name', '1');\n if (!choice) return false;\n\n if (!isNaN(Number(choice))) {\n const idx = Number(choice) - 1;\n selected = AVAILABLE_EXAMPLES[idx];\n } else {\n selected = AVAILABLE_EXAMPLES.find(\n (e) => e.id.toLowerCase() === choice.toLowerCase()\n );\n }\n\n if (!selected) {\n console.log(`\\x1b[31m✕ Unknown example selection: ${choice}\\x1b[0m`);\n return false;\n }\n }\n\n // Destination directory\n const defaultDir = selected.type === 'project' ? `./${selected.id}` : './';\n const targetDir = targetDirInput || (await prompt('Enter destination directory', defaultDir));\n const resolvedTarget = path.resolve(process.cwd(), targetDir);\n\n const sourcePath = path.join(examplesBase, selected.path);\n\n if (!fs.existsSync(sourcePath)) {\n console.log(`\\x1b[31m✕ Could not locate template files at: ${sourcePath}\\x1b[0m`);\n return false;\n }\n\n console.log(`\\n\\x1b[38;2;212;255;50m✦\\x1b[0m Creating \\x1b[1m${selected.name}\\x1b[0m in \\x1b[36m${path.relative(process.cwd(), resolvedTarget) || '.'}\\x1b[0m...`);\n\n if (selected.type === 'project') {\n copyDir(sourcePath, resolvedTarget);\n\n console.log(`\n\\x1b[32m✓ Successfully created ${selected.name}!\u001b[0m\n\n\\x1b[1mNext Steps:\\x1b[0m\n 1. \\x1b[33mcd ${path.relative(process.cwd(), resolvedTarget) || '.'}\\x1b[0m\n 2. \\x1b[33mpnpm install\\x1b[0m (or \\x1b[33mnpm install\\x1b[0m)\n 3. \\x1b[33mcp .env.example .env.local\\x1b[0m and add your API keys\n 4. \\x1b[33mpnpm dev\\x1b[0m to start the app\n`);\n } else {\n // Single file script\n fs.mkdirSync(resolvedTarget, { recursive: true });\n const destFile = path.join(resolvedTarget, path.basename(selected.path));\n fs.copyFileSync(sourcePath, destFile);\n\n console.log(`\n\\x1b[32m✓ Successfully saved ${path.basename(destFile)}!\u001b[0m\n\n\\x1b[1mTo run this example:\\x1b[0m\n \\x1b[33mnpx ts-node ${path.relative(process.cwd(), destFile)}\\x1b[0m\n`);\n }\n\n return true;\n}\n\n/**\n * Handler for CLI command: npx vibezcheck examples [name] [dir]\n */\nexport async function handleExamplesCommand(args: string[]): Promise<void> {\n // If user passed --list or -l\n if (args.includes('--list') || args.includes('-l')) {\n listExamples();\n return;\n }\n\n const exampleParam = args[0] && !args[0].startsWith('-') ? args[0] : undefined;\n const targetDirParam = args[1] && !args[1].startsWith('-') ? args[1] : undefined;\n\n await scaffoldExample(exampleParam, targetDirParam);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAAA,aAAe;AACf,IAAAC,eAAiB;AACjB,IAAAC,mBAAqB;;;ACGd,IAAM,sBAAyD;AAAA;AAAA,EAEpE,eAAe,EAAE,YAAY,GAAK,aAAa,IAAM,kBAAkB,IAAI;AAAA,EAC3E,iBAAiB,EAAE,YAAY,GAAK,aAAa,IAAM,kBAAkB,IAAI;AAAA,EAC7E,gBAAgB,EAAE,YAAY,KAAK,aAAa,KAAK,kBAAkB,KAAK;AAAA,EAC5E,SAAS,EAAE,YAAY,GAAK,aAAa,IAAM,kBAAkB,IAAI;AAAA,EACrE,cAAc,EAAE,YAAY,KAAK,aAAa,KAAK,kBAAkB,KAAK;AAAA,EAC1E,MAA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SAAS,MAAM,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,UAAU;AACnF,QAAM,OAAO,KAAK,SAAS,QAAQ,KAAK,KAAK,SAAS,IAAI;AAE1D,MAAI,MAAM,QAAQ,IAAI;AACtB,QAAM,WAAW,KAAK,QAAQ,OAAO,MAAM,KAAK,KAAK,QAAQ,OAAO,IAAI,KAAK,QAAQ,IAAI;AACzF,MAAI,aAAa,MAAM,KAAK,WAAW,CAAC,GAAG;AACzC,UAAM,KAAK,WAAW,CAAC;AAAA,EACzB;AAEA,QAAM,UAAU,MAAM,SAAS,EAAE,KAAK,KAAK,IAAI,KAAK,CAAC;AACrD,QAAM,mBAAmB,SAAS,EAAE,KAAK,KAAK,IAAI,KAAK,CAAC;AAC1D;AAGA,QAAQ,SAAS;AAAA,EACf,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AACH,gBAAY;AACZ;AAAA,EACF,KAAK;AACH,eAAW;AACX;AAAA,EACF,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AACH,0BAAsB,KAAK,MAAM,CAAC,CAAC;AACnC;AAAA,EACF,KAAK;AAAA,EACL,KAAK;AACH,iBAAa;AACb;AAAA,EACF,KAAK;AAAA,EACL,KAAK;AACH,iBAAa;AACb;AAAA,EACF;AACE,YAAQ,IAAI;AAAA,2BACW,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAQjC;AACG;AACJ;","names":["import_fs","import_path","import_readline","path","fs","readline","import_fs","import_path","import_readline","path","fs","readline","args","path","fs","prompt","readline"]}
|
|
1
|
+
{"version":3,"sources":["../../src/cli/index.ts","../../src/pricing/table.ts","../../src/cli/audit.ts","../../src/cli/examples.ts"],"sourcesContent":["#!/usr/bin/env node\r\n\r\nimport fs from 'fs';\r\nimport path from 'path';\r\nimport readline from 'readline';\r\nimport { MODEL_PRICING_TABLE } from '../pricing/table';\r\nimport { runAudit, displayAuditReport } from './audit';\r\nimport { handleExamplesCommand } from './examples';\r\n\r\nconst args = process.argv.slice(2);\r\nconst command = args[0] || 'init';\r\n\r\nfunction getCliVersion(): string {\r\n try {\r\n const candidates = [\r\n path.resolve(__dirname, '../../package.json'),\r\n path.resolve(__dirname, '../package.json'),\r\n path.resolve(__dirname, './package.json'),\r\n ];\r\n for (const p of candidates) {\r\n if (fs.existsSync(p)) {\r\n const pkg = JSON.parse(fs.readFileSync(p, 'utf-8'));\r\n if (pkg.version) return pkg.version;\r\n }\r\n }\r\n } catch {}\r\n return '0.5.13';\r\n}\r\n\r\nfunction printBanner() {\r\n console.log(`\r\n\\x1b[38;2;212;255;50m✦\\x1b[0m \\x1b[1mvibezcheck CLI\\x1b[0m \\x1b[90mv${getCliVersion()}\\x1b[0m\r\n\\x1b[90mThe 1-line Token Metering & Cost Intelligence Engine for LLMs\\x1b[0m\r\n`);\r\n}\r\n\r\nasync function prompt(question: string, defaultVal: string = ''): Promise<string> {\r\n const rl = readline.createInterface({\r\n input: process.stdin,\r\n output: process.stdout,\r\n });\r\n\r\n return new Promise((resolve) => {\r\n const promptText = defaultVal\r\n ? `\\x1b[32m?\\x1b[0m \\x1b[1m${question}\\x1b[0m \\x1b[90m(${defaultVal})\\x1b[0m: `\r\n : `\\x1b[32m?\\x1b[0m \\x1b[1m${question}\\x1b[0m: `;\r\n\r\n rl.question(promptText, (answer) => {\r\n rl.close();\r\n resolve(answer.trim() || defaultVal);\r\n });\r\n });\r\n}\r\n\r\n/**\r\n * Command: npx vibezcheck init\r\n */\r\nasync function handleInit() {\r\n printBanner();\r\n console.log('\\x1b[1m✦ VibezCheck Project Setup Wizard\\x1b[0m\\n');\r\n\r\n const cwd = process.cwd();\r\n\r\n // Detect project structure\r\n const isNextAppRouter = fs.existsSync(path.join(cwd, 'app'));\r\n const isNextPagesRouter = fs.existsSync(path.join(cwd, 'pages'));\r\n const isSrcDir = fs.existsSync(path.join(cwd, 'src', 'app'));\r\n\r\n console.log(`\\x1b[90mProject directory: ${cwd}\\x1b[0m`);\r\n if (isNextAppRouter || isSrcDir) {\r\n console.log('\\x1b[32m✓ Detected Next.js App Router project\\x1b[0m\\n');\r\n }\r\n\r\n // 1. Prompt for API Keys\r\n const defaultGateway = 'vck_demo_key';\r\n const gatewayKey = await prompt('Enter your OpenAI or AI Gateway API Key', defaultGateway);\r\n\r\n // 2. Create / Update .env.local\r\n const envPath = path.join(cwd, '.env.local');\r\n const envContent = `# VibezCheck AI Configuration\r\nOPENAI_API_KEY=${gatewayKey}\r\nAI_GATEWAY_API_KEY=${gatewayKey}\r\n`;\r\n\r\n fs.writeFileSync(envPath, envContent, { flag: 'w' });\r\n console.log(`\\x1b[32m✓ Created/updated .env.local\\x1b[0m`);\r\n\r\n // 3. Create Sample API Route (app/api/chat/route.ts)\r\n const apiDir = isSrcDir\r\n ? path.join(cwd, 'src', 'app', 'api', 'chat')\r\n : path.join(cwd, 'app', 'api', 'chat');\r\n\r\n fs.mkdirSync(apiDir, { recursive: true });\r\n const routePath = path.join(apiDir, 'route.ts');\r\n\r\n const routeContent = `import { streamText } from 'ai';\r\nimport { openai } from '@ai-sdk/openai';\r\nimport { vibezcheck } from 'vibezcheck';\r\n\r\nexport const runtime = 'nodejs';\r\nexport const dynamic = 'force-dynamic';\r\n\r\nexport async function POST(req: Request) {\r\n const { messages, customerId = 'cus_demo_user' } = await req.json();\r\n\r\n // ⚡ 1-Line Declarative Model Metering\r\n const result = streamText({\r\n model: vibezcheck(openai('gpt-4o-mini'), {\r\n customer: customerId,\r\n pricing: { margin: 1.30 }, // +30% profit markup\r\n safety: { maxCostPerCallUSD: 0.50 }, // Auto-shutoff safety switch\r\n onUsage: (event) => {\r\n console.log(\\`[vibezcheck] Tokens: \\${event.usage.totalTokens} | Cost: $\\${event.cost.totalUSD.toFixed(6)}\\`);\r\n },\r\n }),\r\n messages,\r\n });\r\n\r\n return result.toDataStreamResponse();\r\n}\r\n`;\r\n\r\n fs.writeFileSync(routePath, routeContent, { flag: 'w' });\r\n console.log(`\\x1b[32m✓ Generated metered AI route: ${path.relative(cwd, routePath)}\\x1b[0m`);\r\n\r\n console.log(`\r\n\\x1b[32m\\x1b[1mSetup Complete!\\x1b[0m\r\n\r\n\\x1b[1mNext Steps:\\x1b[0m\r\n 1. Add \\x1b[36m<VibezReceipt />\\x1b[0m under assistant messages:\r\n \\x1b[90mimport { VibezReceipt } from 'vibezcheck/react';\\x1b[0m\r\n\r\n 2. Run your dev server:\r\n \\x1b[33mpnpm dev\\x1b[0m or \\x1b[33mnpm run dev\\x1b[0m\r\n`);\r\n}\r\n\r\n/**\r\n * Command: npx vibezcheck prices\r\n */\r\nfunction handlePrices() {\r\n printBanner();\r\n console.log('\\x1b[1m📊 Official Model Pricing Registry (USD per 1M Tokens):\\x1b[0m\\n');\r\n\r\n console.log(\r\n 'Model'.padEnd(32) +\r\n 'Input / 1M'.padEnd(16) +\r\n 'Output / 1M'.padEnd(16) +\r\n 'Cached / 1M'\r\n );\r\n console.log('-'.repeat(78));\r\n\r\n Object.entries(MODEL_PRICING_TABLE).forEach(([model, rates]) => {\r\n const input = `$${rates.inputPer1M.toFixed(3)}`.padEnd(16);\r\n const output = `$${rates.outputPer1M.toFixed(3)}`.padEnd(16);\r\n const cached = rates.cachedInputPer1M\r\n ? `$${rates.cachedInputPer1M.toFixed(3)}`\r\n : '—';\r\n\r\n console.log(model.padEnd(32) + input + output + cached);\r\n });\r\n}\r\n\r\n/**\r\n * Command: npx vibezcheck doctor\r\n */\r\nfunction handleDoctor() {\r\n printBanner();\r\n console.log('\\x1b[1m🩺 Running VibezCheck System Health Check...\\x1b[0m\\n');\r\n\r\n const cwd = process.cwd();\r\n const envPath = path.join(cwd, '.env.local');\r\n const hasEnv = fs.existsSync(envPath);\r\n\r\n console.log(`Node.js Version: \\x1b[32m${process.version}\\x1b[0m`);\r\n console.log(`Working Directory: \\x1b[90m${cwd}\\x1b[0m`);\r\n console.log(`Environment File: ${hasEnv ? '\\x1b[32m✓ Found (.env.local)\\x1b[0m' : '\\x1b[33m⚠ Missing (.env.local)\\x1b[0m'}`);\r\n console.log(`Telemetry Mode: \\x1b[32m✓ Zero-Dependency In-Memory Active\\x1b[0m`);\r\n\r\n const hasGateway = Boolean(process.env.AI_GATEWAY_API_KEY || process.env.OPENAI_API_KEY);\r\n console.log(`AI Provider Key: ${hasGateway ? '\\x1b[32m✓ Configured\\x1b[0m' : '\\x1b[33m⚠ Missing (Set AI_GATEWAY_API_KEY)\\x1b[0m'}`);\r\n\r\n console.log(`\\n\\x1b[32m✓ VibezCheck engine is healthy and ready to meter!\\x1b[0m\\n`);\r\n}\r\n\r\n/**\r\n * Command: npx vibezcheck audit [--fix] [--ci] [--json] [--dir <path>]\r\n */\r\nasync function handleAudit() {\r\n const fix = args.includes('--fix') || args.includes('-f');\r\n const ci = args.includes('--ci') || args.includes('-s') || args.includes('--strict');\r\n const json = args.includes('--json') || args.includes('-j');\r\n\r\n let dir = process.cwd();\r\n const dirIndex = args.indexOf('--dir') !== -1 ? args.indexOf('--dir') : args.indexOf('-d');\r\n if (dirIndex !== -1 && args[dirIndex + 1]) {\r\n dir = args[dirIndex + 1];\r\n }\r\n\r\n const summary = await runAudit({ dir, fix, ci, json });\r\n await displayAuditReport(summary, { dir, fix, ci, json });\r\n}\r\n\r\n// Router\r\nswitch (command) {\r\n case 'audit':\r\n case 'check':\r\n case 'scan':\r\n handleAudit();\r\n break;\r\n case 'init':\r\n handleInit();\r\n break;\r\n case 'example':\r\n case 'examples':\r\n case 'template':\r\n case 'templates':\r\n handleExamplesCommand(args.slice(1));\r\n break;\r\n case 'prices':\r\n case 'pricing':\r\n handlePrices();\r\n break;\r\n case 'doctor':\r\n case 'health':\r\n handleDoctor();\r\n break;\r\n default:\r\n console.log(`\r\nUnknown command: \\x1b[31m${command}\\x1b[0m\r\n\r\nAvailable commands:\r\n \\x1b[36mvibezcheck examples [name]\\x1b[0m Explore & scaffold official starter templates & scripts\r\n \\x1b[36mvibezcheck audit\\x1b[0m Scan project for unmetered AI routes and runaway loop risks\r\n \\x1b[36mvibezcheck init\\x1b[0m Interactive project setup wizard\r\n \\x1b[36mvibezcheck prices\\x1b[0m Display supported model pricing table\r\n \\x1b[36mvibezcheck doctor\\x1b[0m Diagnose environment and API configurations\r\n`);\r\n break;\r\n}\r\n","import type { ModelPricingRates } from '../types';\r\nimport { getDynamicRate } from './sync';\r\n\r\n/**\r\n * Built-in Registry of Model Pricing (USD per 1 Million Tokens)\r\n * Sourced from official 2026 provider pricing tables.\r\n */\r\nexport const MODEL_PRICING_TABLE: Record<string, ModelPricingRates> = {\r\n // --- OpenAI (Modern & Reasoning) ---\r\n 'gpt-5.6-sol': { inputPer1M: 4.0, outputPer1M: 20.0, cachedInputPer1M: 0.4 },\r\n 'gpt-5.6-terra': { inputPer1M: 2.0, outputPer1M: 12.0, cachedInputPer1M: 0.2 },\r\n 'gpt-5.6-luna': { inputPer1M: 0.2, outputPer1M: 1.2, cachedInputPer1M: 0.02 },\r\n 'gpt-5': { inputPer1M: 4.0, outputPer1M: 20.0, cachedInputPer1M: 0.4 },\r\n 'gpt-5-mini': { inputPer1M: 0.2, outputPer1M: 1.2, cachedInputPer1M: 0.02 },\r\n 'o1': { inputPer1M: 15.0, outputPer1M: 60.0, cachedInputPer1M: 7.5 },\r\n 'o1-mini': { inputPer1M: 1.1, outputPer1M: 4.4, cachedInputPer1M: 0.55 },\r\n 'o3': { inputPer1M: 15.0, outputPer1M: 60.0, cachedInputPer1M: 7.5 },\r\n 'o3-mini': { inputPer1M: 1.1, outputPer1M: 4.4, cachedInputPer1M: 0.55 },\r\n 'gpt-4o': { inputPer1M: 2.5, outputPer1M: 10.0, cachedInputPer1M: 1.25 },\r\n 'gpt-4o-mini': { inputPer1M: 0.15, outputPer1M: 0.6, cachedInputPer1M: 0.075 },\r\n 'gpt-4.5': { inputPer1M: 75.0, outputPer1M: 150.0, cachedInputPer1M: 37.5 },\r\n 'gpt-4.5-preview': { inputPer1M: 75.0, outputPer1M: 150.0, cachedInputPer1M: 37.5 },\r\n 'chatgpt-4o-latest': { inputPer1M: 5.0, outputPer1M: 15.0 },\r\n 'gpt-4.1': { inputPer1M: 2.0, outputPer1M: 8.0, cachedInputPer1M: 1.0 },\r\n 'gpt-4.1-nano': { inputPer1M: 0.1, outputPer1M: 0.4, cachedInputPer1M: 0.05 },\r\n 'gpt-6-astra': { inputPer1M: 5.0, outputPer1M: 25.0, cachedInputPer1M: 0.5 },\r\n 'gpt-6-astra-fast': { inputPer1M: 3.0, outputPer1M: 15.0, cachedInputPer1M: 0.3 },\r\n 'gpt-image-2.5-flare': { inputPer1M: 0.0, outputPer1M: 0.04 },\r\n 'gpt-image-2.5-sunburst': { inputPer1M: 0.0, outputPer1M: 0.08 },\r\n\r\n // --- OpenAI (Legacy & Backward Compatibility) ---\r\n 'gpt-4-turbo': { inputPer1M: 10.0, outputPer1M: 30.0, cachedInputPer1M: 5.0 },\r\n 'gpt-4-turbo-preview': { inputPer1M: 10.0, outputPer1M: 30.0, cachedInputPer1M: 5.0 },\r\n 'gpt-4': { inputPer1M: 30.0, outputPer1M: 60.0 },\r\n 'gpt-4-32k': { inputPer1M: 60.0, outputPer1M: 120.0 },\r\n 'gpt-3.5-turbo': { inputPer1M: 0.5, outputPer1M: 1.5 },\r\n 'gpt-3.5-turbo-16k': { inputPer1M: 3.0, outputPer1M: 4.0 },\r\n 'text-embedding-3-small': { inputPer1M: 0.02, outputPer1M: 0.0 },\r\n 'text-embedding-3-large': { inputPer1M: 0.13, outputPer1M: 0.0 },\r\n 'text-embedding-ada-002': { inputPer1M: 0.10, outputPer1M: 0.0 },\r\n\r\n // --- Anthropic (Modern & Extended Thinking) ---\r\n 'claude-haiku-5.5': { inputPer1M: 0.1, outputPer1M: 0.5, cachedInputPer1M: 0.01 },\r\n 'claude-sonnet-5.5': { inputPer1M: 2.0, outputPer1M: 10.0, cachedInputPer1M: 0.1 },\r\n 'claude-opus-5.5': { inputPer1M: 4.0, outputPer1M: 20.0, cachedInputPer1M: 0.2 },\r\n 'claude-opus-5.5-fast': { inputPer1M: 8.0, outputPer1M: 40.0, cachedInputPer1M: 0.4 },\r\n 'claude-3-7-sonnet': { inputPer1M: 0.59, outputPer1M: 2.93, cachedInputPer1M: 0.3 },\r\n 'claude-sonnet-5': { inputPer1M: 2.0, outputPer1M: 10.0, cachedInputPer1M: 0.3 },\r\n 'claude-3-5-sonnet': { inputPer1M: 3.0, outputPer1M: 15.0, cachedInputPer1M: 0.3 },\r\n 'claude-3-5-haiku': { inputPer1M: 0.8, outputPer1M: 4.0, cachedInputPer1M: 0.08 },\r\n 'haiku-4.5': { inputPer1M: 1.0, outputPer1M: 5.0, cachedInputPer1M: 0.1 },\r\n 'claude-opus-5': { inputPer1M: 5.0, outputPer1M: 25.0, cachedInputPer1M: 1.5 },\r\n 'claude-3-opus': { inputPer1M: 15.0, outputPer1M: 75.0, cachedInputPer1M: 1.5 },\r\n\r\n // --- Anthropic (Legacy & Backward Compatibility) ---\r\n 'claude-3-sonnet': { inputPer1M: 3.0, outputPer1M: 15.0, cachedInputPer1M: 0.3 },\r\n 'claude-3-haiku': { inputPer1M: 0.25, outputPer1M: 1.25, cachedInputPer1M: 0.025 },\r\n 'claude-2.1': { inputPer1M: 8.0, outputPer1M: 24.0 },\r\n 'claude-2.0': { inputPer1M: 8.0, outputPer1M: 24.0 },\r\n 'claude-instant-1.2': { inputPer1M: 1.63, outputPer1M: 5.51 },\r\n\r\n // --- Google Gemini (Modern & Thoughts) ---\r\n 'gemini-3.8-flash': { inputPer1M: 0.75, outputPer1M: 3.75, cachedInputPer1M: 0.075 },\r\n 'gemini-nano-banana-2.1': { inputPer1M: 1.5, outputPer1M: 7.5, cachedInputPer1M: 0.15 },\r\n 'gemini-3.7-flash': { inputPer1M: 0.75, outputPer1M: 3.75, cachedInputPer1M: 0.18 },\r\n 'gemini-3.1-pro': { inputPer1M: 2.0, outputPer1M: 12.0, cachedInputPer1M: 0.5 },\r\n 'gemini-3.5-flash': { inputPer1M: 1.5, outputPer1M: 9.0, cachedInputPer1M: 0.38 },\r\n 'gemini-3.1-flash-lite': { inputPer1M: 0.25, outputPer1M: 1.5, cachedInputPer1M: 0.06 },\r\n 'gemini-2.5-pro': { inputPer1M: 1.25, outputPer1M: 5.0, cachedInputPer1M: 0.3125 },\r\n 'gemini-2.5-flash': { inputPer1M: 0.15, outputPer1M: 0.6, cachedInputPer1M: 0.0375 },\r\n 'gemini-2.0-flash': { inputPer1M: 0.1, outputPer1M: 0.4, cachedInputPer1M: 0.025 },\r\n 'gemini-2.0-flash-lite': { inputPer1M: 0.075, outputPer1M: 0.3, cachedInputPer1M: 0.01875 },\r\n 'gemini-2.0-pro': { inputPer1M: 1.25, outputPer1M: 5.0, cachedInputPer1M: 0.3125 },\r\n\r\n // --- Google Gemini (Legacy & Backward Compatibility) ---\r\n 'gemini-1.5-pro': { inputPer1M: 1.25, outputPer1M: 5.0, cachedInputPer1M: 0.3125 },\r\n 'gemini-1.5-flash': { inputPer1M: 0.075, outputPer1M: 0.3, cachedInputPer1M: 0.01875 },\r\n 'gemini-1.5-flash-8b': { inputPer1M: 0.0375, outputPer1M: 0.15, cachedInputPer1M: 0.009375 },\r\n 'gemini-1.0-pro': { inputPer1M: 0.5, outputPer1M: 1.5 },\r\n\r\n // --- xAI Grok ---\r\n 'grok-4.6': { inputPer1M: 3.0, outputPer1M: 15.0 },\r\n 'grok-3': { inputPer1M: 3.0, outputPer1M: 15.0 },\r\n 'grok-3-mini': { inputPer1M: 0.3, outputPer1M: 1.5 },\r\n 'grok-2': { inputPer1M: 2.0, outputPer1M: 10.0 },\r\n 'grok-2-vision': { inputPer1M: 2.0, outputPer1M: 10.0 },\r\n 'grok-beta': { inputPer1M: 5.0, outputPer1M: 15.0 },\r\n\r\n // --- Mistral ---\r\n 'mistral-large-4': { inputPer1M: 0.68, outputPer1M: 2.09, cachedInputPer1M: 0.07 },\r\n 'mistral-large-3': { inputPer1M: 2.0, outputPer1M: 6.0 },\r\n 'mistral-large-latest': { inputPer1M: 2.0, outputPer1M: 6.0 },\r\n 'mistral-large-2411': { inputPer1M: 2.0, outputPer1M: 6.0 },\r\n 'codestral-latest': { inputPer1M: 0.3, outputPer1M: 0.9 },\r\n 'mistral-medium-latest': { inputPer1M: 2.7, outputPer1M: 8.1 },\r\n 'mistral-medium-3-5': { inputPer1M: 2.0, outputPer1M: 6.0, cachedInputPer1M: 0.4 },\r\n 'mistral-medium-2604': { inputPer1M: 2.0, outputPer1M: 6.0, cachedInputPer1M: 0.4 },\r\n 'magistral-small-latest': { inputPer1M: 0.5, outputPer1M: 1.5, cachedInputPer1M: 0.1 },\r\n 'magistral-medium-latest': { inputPer1M: 2.0, outputPer1M: 6.0, cachedInputPer1M: 0.4 },\r\n 'mistral-small-latest': { inputPer1M: 0.2, outputPer1M: 0.6 },\r\n 'mistral-small-2603': { inputPer1M: 0.2, outputPer1M: 0.6, cachedInputPer1M: 0.05 },\r\n 'mistral-vibe-cli-fast': { inputPer1M: 0.2, outputPer1M: 0.6, cachedInputPer1M: 0.05 },\r\n 'mistral-vibe-cli-latest': { inputPer1M: 0.2, outputPer1M: 0.6, cachedInputPer1M: 0.05 },\r\n 'codestral-2508': { inputPer1M: 0.3, outputPer1M: 0.9, cachedInputPer1M: 0.08 },\r\n 'codestral-embed': { inputPer1M: 0.1, outputPer1M: 0.0 },\r\n 'mistral-embed-2312': { inputPer1M: 0.1, outputPer1M: 0.0 },\r\n 'zai-glm-5-2': { inputPer1M: 0.6, outputPer1M: 2.2, cachedInputPer1M: 0.15 },\r\n 'glm-5-2': { inputPer1M: 0.6, outputPer1M: 2.2, cachedInputPer1M: 0.15 },\r\n 'labs-leanstral-1-5': { inputPer1M: 0.2, outputPer1M: 0.6, cachedInputPer1M: 0.05 },\r\n 'ministral-8b-latest': { inputPer1M: 0.1, outputPer1M: 0.1 },\r\n 'ministral-3b-latest': { inputPer1M: 0.04, outputPer1M: 0.04 },\r\n 'open-mistral-7b': { inputPer1M: 0.2, outputPer1M: 0.2 },\r\n 'open-mixtral-8x7b': { inputPer1M: 0.7, outputPer1M: 0.7 },\r\n 'open-mixtral-8x22b': { inputPer1M: 2.0, outputPer1M: 6.0 },\r\n\r\n // --- Groq & Meta Llama LPUs ---\r\n 'llama-3.3-70b-versatile': { inputPer1M: 0.59, outputPer1M: 0.79 },\r\n 'llama-3.1-405b': { inputPer1M: 3.0, outputPer1M: 3.0 },\r\n 'llama-3.1-70b-versatile': { inputPer1M: 0.59, outputPer1M: 0.79 },\r\n 'llama-3.1-8b-instant': { inputPer1M: 0.05, outputPer1M: 0.08 },\r\n 'llama-3.2-1b-preview': { inputPer1M: 0.04, outputPer1M: 0.04 },\r\n 'llama-3.2-3b-preview': { inputPer1M: 0.06, outputPer1M: 0.06 },\r\n 'llama-3.2-11b-vision': { inputPer1M: 0.18, outputPer1M: 0.18 },\r\n 'llama-3.2-90b-vision': { inputPer1M: 0.90, outputPer1M: 0.90 },\r\n 'deepseek-r1-distill-llama-70b': { inputPer1M: 0.75, outputPer1M: 0.99 },\r\n 'deepseek-r1-distill-qwen-32b': { inputPer1M: 0.49, outputPer1M: 0.49 },\r\n 'qwen-2.5-32b': { inputPer1M: 0.29, outputPer1M: 0.39 },\r\n 'qwen-2.5-72b': { inputPer1M: 0.35, outputPer1M: 0.40 },\r\n 'mixtral-8x7b-32768': { inputPer1M: 0.24, outputPer1M: 0.24 },\r\n 'gemma2-9b-it': { inputPer1M: 0.20, outputPer1M: 0.20 },\r\n\r\n // --- DeepSeek ---\r\n 'deepseek-v4-pro': { inputPer1M: 0.66, outputPer1M: 1.98, cachedInputPer1M: 0.15 },\r\n 'deepseek-v4.1-flash': { inputPer1M: 0.20, outputPer1M: 0.60, cachedInputPer1M: 0.05 },\r\n 'deepseek-v4-flash': { inputPer1M: 0.22, outputPer1M: 0.66, cachedInputPer1M: 0.05 },\r\n 'deepseek-v3': { inputPer1M: 0.14, outputPer1M: 0.28, cachedInputPer1M: 0.014 },\r\n 'deepseek-chat': { inputPer1M: 0.14, outputPer1M: 0.28, cachedInputPer1M: 0.014 },\r\n 'deepseek-r1': { inputPer1M: 0.55, outputPer1M: 2.19, cachedInputPer1M: 0.14 },\r\n 'deepseek-reasoner': { inputPer1M: 0.55, outputPer1M: 2.19, cachedInputPer1M: 0.14 },\r\n\r\n // --- Gateway, Inception & InclusionAI Models ---\r\n 'mercury-2.5': { inputPer1M: 0.25, outputPer1M: 0.75, cachedInputPer1M: 0.05 },\r\n 'mercury-2': { inputPer1M: 0.25, outputPer1M: 0.75, cachedInputPer1M: 0.05 },\r\n 'ling-3.0-flash-sante': { inputPer1M: 0.15, outputPer1M: 0.45, cachedInputPer1M: 0.03 },\r\n 'ling-3.0-flash': { inputPer1M: 0.15, outputPer1M: 0.45, cachedInputPer1M: 0.03 },\r\n\r\n // --- Cohere ---\r\n 'command-r-plus': { inputPer1M: 2.5, outputPer1M: 10.0 },\r\n 'command-r': { inputPer1M: 0.15, outputPer1M: 0.6 },\r\n 'command': { inputPer1M: 1.0, outputPer1M: 2.0 },\r\n 'command-light': { inputPer1M: 0.3, outputPer1M: 0.6 },\r\n 'embed-english-v3.0': { inputPer1M: 0.10, outputPer1M: 0.0 },\r\n\r\n // --- Perplexity ---\r\n 'sonar': { inputPer1M: 1.0, outputPer1M: 1.0 },\r\n 'sonar-pro': { inputPer1M: 3.0, outputPer1M: 15.0 },\r\n 'sonar-reasoning': { inputPer1M: 1.0, outputPer1M: 5.0 },\r\n 'sonar-reasoning-pro': { inputPer1M: 2.0, outputPer1M: 8.0 },\r\n};\r\n\r\n/**\r\n * Common model alias map to normalize nicknames, shorthands, and legacy IDs\r\n */\r\nexport const MODEL_ALIASES: Record<string, string> = {\r\n // OpenAI Shorthands & Aliases\r\n 'gpt4': 'gpt-4',\r\n 'gpt4o': 'gpt-4o',\r\n 'gpt-4-preview': 'gpt-4-turbo',\r\n 'gpt-4-0125-preview': 'gpt-4-turbo',\r\n 'gpt-4-1106-preview': 'gpt-4-turbo',\r\n 'gpt-3.5': 'gpt-3.5-turbo',\r\n 'gpt-3.5-turbo-0125': 'gpt-3.5-turbo',\r\n 'gpt-3.5-turbo-1106': 'gpt-3.5-turbo',\r\n 'gpt-3.5-turbo-16k-0613': 'gpt-3.5-turbo-16k',\r\n\r\n // Anthropic Shorthands\r\n 'sonnet': 'claude-3-5-sonnet',\r\n 'sonnet-3.7': 'claude-3-7-sonnet',\r\n 'sonnet-3.5': 'claude-3-5-sonnet',\r\n 'haiku': 'claude-3-5-haiku',\r\n 'haiku-3.5': 'claude-3-5-haiku',\r\n 'haiku-5.5': 'claude-haiku-5.5',\r\n 'sonnet-5.5': 'claude-sonnet-5.5',\r\n 'opus-5.5': 'claude-opus-5.5',\r\n 'opus': 'claude-3-opus',\r\n 'claude-2': 'claude-2.0',\r\n 'claude-instant': 'claude-instant-1.2',\r\n\r\n // DeepSeek Shorthands\r\n 'r1': 'deepseek-r1',\r\n 'v3': 'deepseek-v3',\r\n\r\n // Gemini Shorthands\r\n 'flash': 'gemini-2.0-flash',\r\n 'pro': 'gemini-1.5-pro',\r\n 'gemini-banana': 'gemini-nano-banana-2.1',\r\n\r\n // Meta / Groq Shorthands\r\n 'llama-3.3-70b': 'llama-3.3-70b-versatile',\r\n 'llama-3.1-70b': 'llama-3.1-70b-versatile',\r\n 'llama-3.1-8b': 'llama-3.1-8b-instant',\r\n 'llama-3-70b': 'llama-3.1-70b-versatile',\r\n 'llama-3-8b': 'llama-3.1-8b-instant',\r\n\r\n // Mistral Shorthands\r\n 'codestral': 'codestral-latest',\r\n 'mistral-large': 'mistral-large-latest',\r\n 'mistral-small': 'mistral-small-latest',\r\n 'magistral': 'magistral-small-latest',\r\n 'magistral-small': 'magistral-small-latest',\r\n 'magistral-medium': 'magistral-medium-latest',\r\n 'mistral-3.5': 'mistral-medium-3-5',\r\n 'mistral-medium-3.5': 'mistral-medium-3-5',\r\n 'gpt-image-2.5': 'gpt-image-2.5-flare',\r\n 'gpt-image-sunburst': 'gpt-image-2.5-sunburst',\r\n 'gpt-image-flare': 'gpt-image-2.5-flare',\r\n};\r\n\r\n/**\r\n * Dynamic in-memory registry allowing runtime custom price registration\r\n */\r\nconst customPricingRegistry: Record<string, ModelPricingRates> = {};\r\n\r\n/**\r\n * Normalize model identifier to match pricing table keys:\r\n * - Strips AWS Bedrock prefixes (e.g. 'anthropic.claude-3-5-sonnet-20241022-v2:0' -> 'claude-3-5-sonnet')\r\n * - Strips provider prefixes (e.g. 'openai/gpt-4o' -> 'gpt-4o', 'deepseek/deepseek-r1' -> 'deepseek-r1')\r\n * - Strips date suffixes (e.g. '-20240307', '-20250219')\r\n * - Resolves shorthands and aliases\r\n */\r\nexport function normalizeModelKey(rawModel: string): string {\r\n if (!rawModel) return 'unknown';\r\n\r\n let model = rawModel.toLowerCase().trim();\r\n\r\n // Strip AWS Bedrock model prefix (e.g. 'us.anthropic.claude-3-5-sonnet...', 'meta.llama3-...')\r\n model = model.replace(/^[a-z0-9_-]+\\.(anthropic|meta|amazon|cohere|mistral|ai21)\\./i, '');\r\n model = model.replace(/^(anthropic|meta|amazon|cohere|mistral|ai21)\\./i, '');\r\n\r\n // Strip AWS Bedrock version suffix (e.g. '-v1:0', '-v2:0', ':0')\r\n model = model.replace(/-v\\d+(:\\d+)?$/, '');\r\n model = model.replace(/:\\d+$/, '');\r\n\r\n // Strip provider prefix if present (e.g. 'openai/gpt-4o' -> 'gpt-4o', 'meta-llama/llama-3.3-70b-instruct' -> 'llama-3.3-70b-instruct')\r\n if (model.includes('/')) {\r\n model = model.split('/').slice(1).join('/');\r\n }\r\n\r\n // Remove trailing version/mode tags (e.g. ':latest', ':free', ':beta')\r\n model = model.replace(/:(latest|free|beta)$/, '');\r\n\r\n // Remove date suffixes like -20240307 or -20250219 or -2024-08-06\r\n model = model.replace(/-\\d{8}$/, '');\r\n model = model.replace(/-\\d{4}-\\d{2}-\\d{2}$/, '');\r\n\r\n // Normalize Bedrock Meta format (e.g. llama3-1-70b -> llama-3.1-70b)\r\n model = model.replace(/llama(\\d+)-(\\d+)-/g, 'llama-$1.$2-');\r\n model = model.replace(/llama(\\d+)\\.(\\d+)-/g, 'llama-$1.$2-');\r\n\r\n // Check aliases before fine-tuning\r\n if (MODEL_ALIASES[model]) {\r\n return MODEL_ALIASES[model];\r\n }\r\n\r\n // Remove common modifier suffixes if not directly matching table\r\n if (!MODEL_PRICING_TABLE[model]) {\r\n const withoutInstruct = model.replace(/-(instruct|chat|preview)$/, '');\r\n if (MODEL_PRICING_TABLE[withoutInstruct]) {\r\n return withoutInstruct;\r\n }\r\n if (MODEL_ALIASES[withoutInstruct]) {\r\n return MODEL_ALIASES[withoutInstruct];\r\n }\r\n }\r\n\r\n return model;\r\n}\r\n\r\n/**\r\n * Retrieve pricing rates for a given model\r\n */\r\nexport function getModelPricing(modelName: string): ModelPricingRates {\r\n const normalized = normalizeModelKey(modelName);\r\n\r\n // Check custom registry first\r\n if (customPricingRegistry[normalized]) {\r\n return customPricingRegistry[normalized];\r\n }\r\n if (customPricingRegistry[modelName]) {\r\n return customPricingRegistry[modelName];\r\n }\r\n\r\n // Check dynamic synced manifest cache\r\n const dynamicRate = getDynamicRate(modelName) || getDynamicRate(normalized);\r\n if (dynamicRate) {\r\n return dynamicRate;\r\n }\r\n\r\n // Check built-in table with normalized key\r\n if (MODEL_PRICING_TABLE[normalized]) {\r\n return MODEL_PRICING_TABLE[normalized];\r\n }\r\n // Check built-in table with direct key\r\n if (MODEL_PRICING_TABLE[modelName]) {\r\n return MODEL_PRICING_TABLE[modelName];\r\n }\r\n\r\n // Check alias table fallback\r\n const alias = MODEL_ALIASES[modelName.toLowerCase().trim()];\r\n if (alias) {\r\n const dynamicAlias = getDynamicRate(alias);\r\n if (dynamicAlias) return dynamicAlias;\r\n if (MODEL_PRICING_TABLE[alias]) {\r\n return MODEL_PRICING_TABLE[alias];\r\n }\r\n }\r\n\r\n // Fallback defaults for unknown models (conservative estimates: $1.00 in, $3.00 out)\r\n return {\r\n inputPer1M: 1.0,\r\n outputPer1M: 3.0,\r\n cachedInputPer1M: 0.5,\r\n };\r\n}\r\n\r\n/**\r\n * Register or override pricing rates for a custom model\r\n */\r\nexport function registerModelPricing(modelName: string, rates: ModelPricingRates): void {\r\n const normalized = normalizeModelKey(modelName);\r\n customPricingRegistry[normalized] = rates;\r\n customPricingRegistry[modelName] = rates;\r\n}\r\n","import fs from 'fs';\r\nimport path from 'path';\r\nimport readline from 'readline';\r\n\r\nexport interface RouteAuditFinding {\r\n file: string;\r\n relativePath: string;\r\n status: 'protected' | 'unmetered' | 'unprotected_direct';\r\n line: number;\r\n rawSnippet: string;\r\n suggestedFix?: string;\r\n modelOrProvider?: string;\r\n details: string;\r\n}\r\n\r\nexport interface AuditOptions {\r\n dir?: string;\r\n fix?: boolean;\r\n ci?: boolean;\r\n json?: boolean;\r\n silent?: boolean;\r\n}\r\n\r\nexport interface AuditSummary {\r\n scannedFiles: number;\r\n aiRoutesCount: number;\r\n protectedCount: number;\r\n unmeteredCount: number;\r\n scanTimeMs: number;\r\n findings: RouteAuditFinding[];\r\n}\r\n\r\nconst IGNORED_DIRS = new Set([\r\n 'node_modules',\r\n '.next',\r\n '.git',\r\n 'dist',\r\n 'build',\r\n '.turbo',\r\n 'coverage',\r\n '.cache',\r\n '.vercel',\r\n 'tests',\r\n 'test',\r\n '__tests__',\r\n 'examples',\r\n 'fixtures',\r\n]);\r\n\r\nconst EXTENSIONS = new Set(['.ts', '.tsx', '.js', '.jsx', '.mjs']);\r\n\r\n/**\r\n * Discovers API and server route files in the project.\r\n */\r\nexport function findRouteFiles(rootDir: string): string[] {\r\n const targetSubdirs = [\r\n path.join('app', 'api'),\r\n path.join('src', 'app', 'api'),\r\n path.join('pages', 'api'),\r\n path.join('src', 'pages', 'api'),\r\n 'routes',\r\n path.join('src', 'routes'),\r\n path.join('server', 'api'),\r\n path.join('server', 'routes'),\r\n ];\r\n\r\n const foundFiles: string[] = [];\r\n\r\n // Check designated route directories first\r\n let searchedDesignated = false;\r\n for (const rel of targetSubdirs) {\r\n const full = path.join(rootDir, rel);\r\n if (fs.existsSync(full)) {\r\n searchedDesignated = true;\r\n scanDirRecursive(full, foundFiles);\r\n }\r\n }\r\n\r\n // If no designated route folders exist or very few files, scan app/ and src/app/\r\n if (foundFiles.length === 0) {\r\n const appDir = fs.existsSync(path.join(rootDir, 'app'))\r\n ? path.join(rootDir, 'app')\r\n : fs.existsSync(path.join(rootDir, 'src', 'app'))\r\n ? path.join(rootDir, 'src', 'app')\r\n : rootDir;\r\n\r\n scanDirRecursive(appDir, foundFiles);\r\n }\r\n\r\n return Array.from(new Set(foundFiles));\r\n}\r\n\r\nfunction scanDirRecursive(currentDir: string, results: string[]): void {\r\n try {\r\n const entries = fs.readdirSync(currentDir, { withFileTypes: true });\r\n for (const entry of entries) {\r\n if (entry.isDirectory()) {\r\n if (!IGNORED_DIRS.has(entry.name)) {\r\n scanDirRecursive(path.join(currentDir, entry.name), results);\r\n }\r\n } else if (entry.isFile()) {\r\n const ext = path.extname(entry.name);\r\n if (EXTENSIONS.has(ext)) {\r\n // Exclude spec/test files\r\n if (!entry.name.includes('.test.') && !entry.name.includes('.spec.')) {\r\n results.push(path.join(currentDir, entry.name));\r\n }\r\n }\r\n }\r\n }\r\n } catch {\r\n // Gracefully ignore inaccessible dirs\r\n }\r\n}\r\n\r\n/**\r\n * Audits a single file for AI SDK and LLM usage.\r\n */\r\nexport function auditFile(filePath: string, rootDir: string): RouteAuditFinding[] {\r\n const relativePath = path.relative(rootDir, filePath).replace(/\\\\/g, '/');\r\n let content = '';\r\n try {\r\n content = fs.readFileSync(filePath, 'utf-8');\r\n } catch {\r\n return [];\r\n }\r\n\r\n // Fast pre-filter: Does this file even reference AI libraries?\r\n const hasAiKeywords =\r\n content.includes('streamText') ||\r\n content.includes('generateText') ||\r\n content.includes('streamObject') ||\r\n content.includes('generateObject') ||\r\n content.includes('OpenAI') ||\r\n content.includes('Anthropic') ||\r\n content.includes('vibezcheck');\r\n\r\n if (!hasAiKeywords) {\r\n return [];\r\n }\r\n\r\n const lines = content.split(/\\r?\\n/);\r\n const findings: RouteAuditFinding[] = [];\r\n\r\n // Check 1: Vercel AI SDK usage (streamText, generateText, etc.)\r\n const aiSdkRegex = /\\b(streamText|generateText|streamObject|generateObject)\\s*\\(\\s*\\{/g;\r\n let match: RegExpExecArray | null;\r\n\r\n while ((match = aiSdkRegex.exec(content)) !== null) {\r\n const matchIndex = match.index;\r\n const lineNumber = content.substring(0, matchIndex).split(/\\r?\\n/).length;\r\n\r\n // Scan forward a few lines (up to 25 lines) to inspect the `model:` argument\r\n const snippetLines = lines.slice(lineNumber - 1, lineNumber + 25);\r\n const snippet = snippetLines.join('\\n');\r\n\r\n // Look for model:\r\n const modelLineMatch = snippet.match(/model\\s*:\\s*([^,\\n}]+)/);\r\n if (modelLineMatch) {\r\n const modelExpr = modelLineMatch[1].trim();\r\n const modelLineOffset = snippetLines.findIndex((l) => l.includes('model:'));\r\n const actualLine = lineNumber + (modelLineOffset >= 0 ? modelLineOffset : 0);\r\n const rawSnippet = lines[actualLine - 1] || modelLineMatch[0];\r\n\r\n const isProtected =\r\n modelExpr.includes('vibezcheck(') ||\r\n modelExpr.includes('session.model(') ||\r\n modelExpr.includes('vz.model(');\r\n\r\n if (isProtected) {\r\n findings.push({\r\n file: filePath,\r\n relativePath,\r\n status: 'protected',\r\n line: actualLine,\r\n rawSnippet,\r\n modelOrProvider: modelExpr,\r\n details: 'Metered with 0ms added latency and $0.50 safety fuse ceiling',\r\n });\r\n } else {\r\n // Raw unmetered AI call\r\n const suggestedFix = `model: vibezcheck(${modelExpr}),`;\r\n findings.push({\r\n file: filePath,\r\n relativePath,\r\n status: 'unmetered',\r\n line: actualLine,\r\n rawSnippet,\r\n suggestedFix,\r\n modelOrProvider: modelExpr,\r\n details: 'Direct provider call without cost limit or token metering',\r\n });\r\n }\r\n }\r\n }\r\n\r\n // Check 2: Direct raw client instantiation (new OpenAI(), new Anthropic())\r\n for (let i = 0; i < lines.length; i++) {\r\n const line = lines[i];\r\n if (\r\n (line.includes('new OpenAI(') || line.includes('new Anthropic(')) &&\r\n !content.includes('vibezcheck') &&\r\n !content.includes('wrapStream') &&\r\n !content.includes('trackUsage')\r\n ) {\r\n findings.push({\r\n file: filePath,\r\n relativePath,\r\n status: 'unprotected_direct',\r\n line: i + 1,\r\n rawSnippet: line.trim(),\r\n details: 'Direct client instance without circuit breaker fuse',\r\n });\r\n break; // One direct warning per file is sufficient\r\n }\r\n }\r\n\r\n return findings;\r\n}\r\n\r\n/**\r\n * Runs the audit across the project.\r\n */\r\nexport async function runAudit(options: AuditOptions = {}): Promise<AuditSummary> {\r\n const startTime = Date.now();\r\n const rootDir = options.dir ? path.resolve(options.dir) : process.cwd();\r\n\r\n const files = findRouteFiles(rootDir);\r\n const allFindings: RouteAuditFinding[] = [];\r\n\r\n for (const file of files) {\r\n const findings = auditFile(file, rootDir);\r\n allFindings.push(...findings);\r\n }\r\n\r\n const protectedCount = allFindings.filter((f) => f.status === 'protected').length;\r\n const unmeteredCount = allFindings.filter(\r\n (f) => f.status === 'unmetered' || f.status === 'unprotected_direct'\r\n ).length;\r\n\r\n const summary: AuditSummary = {\r\n scannedFiles: files.length,\r\n aiRoutesCount: allFindings.length,\r\n protectedCount,\r\n unmeteredCount,\r\n scanTimeMs: Date.now() - startTime,\r\n findings: allFindings,\r\n };\r\n\r\n return summary;\r\n}\r\n\r\n/**\r\n * Safely applies the 1-line vibezcheck wrap to an unmetered file.\r\n * Creates a `.bak` backup copy first.\r\n */\r\nexport function applyFixToFile(filePath: string): boolean {\r\n try {\r\n const content = fs.readFileSync(filePath, 'utf-8');\r\n\r\n // Create backup\r\n fs.writeFileSync(`${filePath}.bak`, content, 'utf-8');\r\n\r\n let updated = content;\r\n\r\n // 1. Ensure import exists\r\n if (!updated.includes(\"from 'vibezcheck'\") && !updated.includes('from \"vibezcheck\"')) {\r\n // Find the last import statement or place at top\r\n const importRegex = /^import\\s+.*?;\\s*$/gm;\r\n let lastImportMatch: RegExpExecArray | null = null;\r\n let match: RegExpExecArray | null;\r\n while ((match = importRegex.exec(updated)) !== null) {\r\n lastImportMatch = match;\r\n }\r\n\r\n const importStatement = \"import { vibezcheck } from 'vibezcheck';\\n\";\r\n if (lastImportMatch) {\r\n const insertPos = lastImportMatch.index + lastImportMatch[0].length;\r\n updated = updated.slice(0, insertPos) + '\\n' + importStatement + updated.slice(insertPos);\r\n } else {\r\n updated = importStatement + updated;\r\n }\r\n }\r\n\r\n // 2. Wrap model: <expr> with vibezcheck(<expr>)\r\n // Regex matches: model:\\s*([a-zA-Z0-9_$]+(?:\\([^)]*\\)|'[^']*'|\"[^\"]*\"))\r\n updated = updated.replace(\r\n /model\\s*:\\s*(?!vibezcheck\\()([a-zA-Z0-9_$]+(?:\\([^)]*\\)|'[^']*'|\"[^\"]*\"))/g,\r\n 'model: vibezcheck($1)'\r\n );\r\n\r\n fs.writeFileSync(filePath, updated, 'utf-8');\r\n return true;\r\n } catch {\r\n return false;\r\n }\r\n}\r\n\r\n/**\r\n * Renders the kind, minimalist terminal output.\r\n */\r\nexport async function displayAuditReport(\r\n summary: AuditSummary,\r\n options: AuditOptions = {}\r\n): Promise<void> {\r\n // If JSON mode requested, output raw JSON and return\r\n if (options.json) {\r\n console.log(JSON.stringify(summary, null, 2));\r\n if (options.ci && summary.unmeteredCount > 0) {\r\n process.exit(1);\r\n }\r\n return;\r\n }\r\n\r\n console.log(`\\n\\x1b[38;2;212;255;50m✦\\x1b[0m \\x1b[1mvibezcheck audit\\x1b[0m \\x1b[90m(${summary.scanTimeMs}ms)\\x1b[0m\\n`);\r\n\r\n // Case 1: No AI routes detected\r\n if (summary.aiRoutesCount === 0) {\r\n console.log(` \\x1b[90mNo AI routes detected across ${summary.scannedFiles} files.\\x1b[0m`);\r\n console.log(` Ready to build your first metered route? Run: \\x1b[36mnpx vibezcheck init\\x1b[0m\\n`);\r\n return;\r\n }\r\n\r\n // Case 2: All routes protected (The Calm State)\r\n if (summary.unmeteredCount === 0) {\r\n const message =\r\n summary.protectedCount === 1\r\n ? '✓ The AI route is metered with a $0.50 safety fuse.'\r\n : `✓ All ${summary.protectedCount} AI routes are metered with $0.50 safety fuses.`;\r\n console.log(` \\x1b[32m${message}\\x1b[0m`);\r\n console.log(` \\x1b[90mYour wallet is protected. You're good to ship.\\x1b[0m\\n`);\r\n return;\r\n }\r\n\r\n // Case 3: Unmetered routes found (The Kind Companion)\r\n const unmeteredFindings = summary.findings.filter((f) => f.status !== 'protected');\r\n const countWord = unmeteredFindings.length === 1 ? 'route' : 'routes';\r\n\r\n console.log(\r\n ` We noticed \\x1b[33m${unmeteredFindings.length} ${countWord}\\x1b[0m calling AI providers directly without a safety fuse:\\n`\r\n );\r\n\r\n for (const finding of unmeteredFindings) {\r\n console.log(` \\x1b[1m→ ${finding.relativePath}:${finding.line}\\x1b[0m`);\r\n console.log(` \\x1b[90mCurrent:\\x1b[0m \\x1b[31m${finding.rawSnippet.trim()}\\x1b[0m`);\r\n if (finding.suggestedFix) {\r\n console.log(` \\x1b[90m1-Line Fix:\\x1b[0m \\x1b[32m${finding.suggestedFix}\\x1b[0m`);\r\n }\r\n console.log('');\r\n }\r\n\r\n console.log(` \\x1b[1mWhy this matters:\\x1b[0m`);\r\n console.log(` \\x1b[90mUnmetered routes bill directly to your credit card without runaway limits.`);\r\n console.log(` Wrapping them adds 0ms token metering, $0.50 runaway fuses, and prompt cache discounts.\\x1b[0m\\n`);\r\n\r\n // Auto-fix handling\r\n if (options.fix) {\r\n let fixedCount = 0;\r\n const uniqueFiles = Array.from(new Set(unmeteredFindings.map((f) => f.file)));\r\n for (const file of uniqueFiles) {\r\n if (applyFixToFile(file)) {\r\n fixedCount++;\r\n const rel = path.relative(process.cwd(), file).replace(/\\\\/g, '/');\r\n console.log(` \\x1b[32m✓ Safely wrapped ${rel}\\x1b[0m \\x1b[90m(backup saved as .bak)\\x1b[0m`);\r\n }\r\n }\r\n console.log(`\\n \\x1b[32m\\x1b[1m🎉 All done!\\x1b[0m \\x1b[90mRun tests or build to verify.\\x1b[0m\\n`);\r\n return;\r\n }\r\n\r\n // Interactive prompt if TTY and not CI\r\n if (!options.ci && process.stdin.isTTY) {\r\n const rl = readline.createInterface({\r\n input: process.stdin,\r\n output: process.stdout,\r\n });\r\n\r\n const answer = await new Promise<string>((resolve) => {\r\n rl.question(\r\n ` \\x1b[38;2;212;255;50m⚡ Would you like VibezCheck to safely wrap these routes for you? (y/N): \\x1b[0m`,\r\n (ans) => {\r\n rl.close();\r\n resolve(ans.trim().toLowerCase());\r\n }\r\n );\r\n });\r\n\r\n if (answer === 'y' || answer === 'yes') {\r\n const uniqueFiles = Array.from(new Set(unmeteredFindings.map((f) => f.file)));\r\n for (const file of uniqueFiles) {\r\n if (applyFixToFile(file)) {\r\n const rel = path.relative(process.cwd(), file).replace(/\\\\/g, '/');\r\n console.log(` \\x1b[32m✓ Safely wrapped ${rel}\\x1b[0m \\x1b[90m(backup saved as .bak)\\x1b[0m`);\r\n }\r\n }\r\n console.log(`\\n \\x1b[32m\\x1b[1m🎉 All done!\\x1b[0m \\x1b[90mRun tests or build to verify.\\x1b[0m\\n`);\r\n return;\r\n }\r\n }\r\n\r\n // If CI mode and unmetered found, exit with non-zero\r\n if (options.ci) {\r\n console.log(` \\x1b[31m✖ CI check failed: ${summary.unmeteredCount} unmetered route(s) found.\\x1b[0m\\n`);\r\n process.exit(1);\r\n }\r\n}\r\n","import fs from 'fs';\nimport path from 'path';\nimport readline from 'readline';\n\nexport interface ExampleMeta {\n id: string;\n name: string;\n type: 'project' | 'script';\n description: string;\n framework: string;\n path: string;\n tags: string[];\n}\n\nexport const AVAILABLE_EXAMPLES: ExampleMeta[] = [\n {\n id: 'nextjs-saas-starter',\n name: 'Next.js 15 AI SaaS Starter',\n type: 'project',\n description: 'Production B2B SaaS with customer wallets, <VibezReceipt />, margins & 2026 models',\n framework: 'Next.js 15 (App Router)',\n path: 'nextjs-saas-starter',\n tags: ['Next.js 15', 'React 19', 'Full SaaS'],\n },\n {\n id: 'nextjs-app-router-openai',\n name: 'Next.js App Router OpenAI Minimal',\n type: 'project',\n description: 'Minimal 1-line streamText model wrapper with @ai-sdk/openai, auto-metering & safety fuse',\n framework: 'Next.js 15 (App Router)',\n path: 'nextjs-app-router-openai',\n tags: ['Next.js 15', 'OpenAI', '1-Line Wrapper'],\n },\n {\n id: '01-local-cost-meter',\n name: 'Local Token & Cost Calculator',\n type: 'script',\n description: 'Free standalone inference cost calculation and token aggregation with zero dependencies',\n framework: 'TypeScript / Node.js',\n path: '01-local-cost-meter.ts',\n tags: ['Zero Config', 'Free', 'Local'],\n },\n {\n id: '02-vercel-ai-sdk',\n name: 'AI SDK Multi-Tenant Route Wrapper',\n type: 'script',\n description: 'B2B multi-tenant model wrapper with organization metadata, 30% profit margin & runaway fuse',\n framework: 'AI SDK / TypeScript',\n path: '02-vercel-ai-sdk.ts',\n tags: ['B2B', 'Multi-Tenant', 'Margins'],\n },\n {\n id: '03-native-openai-stream',\n name: 'Native OpenAI Stream Tracking',\n type: 'script',\n description: 'Wrap native openai.chat.completions.create streams with 0ms added latency',\n framework: 'OpenAI SDK',\n path: '03-native-openai-stream.ts',\n tags: ['Native SDK', '0ms Latency'],\n },\n {\n id: '04-claude-thinking',\n name: 'Claude 3.7 Sonnet Extended Thinking',\n type: 'script',\n description: 'Track reasoning and thinking token streams with Anthropic SDK',\n framework: 'Anthropic SDK',\n path: '04-claude-thinking.ts',\n tags: ['Reasoning', 'Claude 3.7', 'Thinking'],\n },\n {\n id: '05-reasoning-agent-stream',\n name: 'Autonomous Reasoning Agent Loop',\n type: 'script',\n description: 'Multi-step agent loop handling reasoning deltas, prompt caching & runaway circuit breaker',\n framework: 'AI SDK / Agents',\n path: '05-reasoning-agent-stream.ts',\n tags: ['Agents', 'Reasoning Deltas', 'Safety Fuse'],\n },\n];\n\n/**\n * Locate the examples directory across local workspace and installed package paths\n */\nexport function findExamplesDir(): string {\n const candidates = [\n path.resolve(__dirname, '../../examples'),\n path.resolve(__dirname, '../examples'),\n path.resolve(__dirname, '../../../examples'),\n path.resolve(process.cwd(), 'examples'),\n path.resolve(process.cwd(), 'node_modules/vibezcheck/examples'),\n ];\n\n for (const c of candidates) {\n if (fs.existsSync(c)) {\n return c;\n }\n }\n\n return path.resolve(__dirname, '../../examples');\n}\n\n/**\n * Copy directory recursively, skipping node_modules and transient folders\n */\nexport function copyDir(src: string, dest: string): void {\n fs.mkdirSync(dest, { recursive: true });\n const entries = fs.readdirSync(src, { withFileTypes: true });\n\n for (const entry of entries) {\n const srcPath = path.join(src, entry.name);\n const destPath = path.join(dest, entry.name);\n\n if (entry.isDirectory()) {\n if (['node_modules', '.next', '.git', 'dist', 'coverage', '.turbo'].includes(entry.name)) {\n continue;\n }\n copyDir(srcPath, destPath);\n } else {\n if (entry.name === '.env.local' || entry.name.endsWith('.log')) {\n continue;\n }\n fs.copyFileSync(srcPath, destPath);\n }\n }\n}\n\nasync function prompt(question: string, defaultVal: string = ''): Promise<string> {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n return new Promise((resolve) => {\n const promptText = defaultVal\n ? `\\x1b[32m?\\x1b[0m \\x1b[1m${question}\\x1b[0m \\x1b[90m(${defaultVal})\\x1b[0m: `\n : `\\x1b[32m?\\x1b[0m \\x1b[1m${question}\\x1b[0m: `;\n\n rl.question(promptText, (answer) => {\n rl.close();\n resolve(answer.trim() || defaultVal);\n });\n });\n}\n\n/**\n * Display formatted catalogue of all available examples\n */\nexport function listExamples(): void {\n console.log('\\x1b[1m✦ VibezCheck Official Examples & Starters\\x1b[0m\\n');\n\n AVAILABLE_EXAMPLES.forEach((ex, index) => {\n const num = `[${index + 1}]`.padEnd(4);\n const typeTag = ex.type === 'project' \n ? '\\x1b[42m\\x1b[30m PROJECT \\x1b[0m' \n : '\\x1b[44m\\x1b[37m SCRIPT \\x1b[0m';\n \n console.log(`${num} ${typeTag} \\x1b[1m${ex.name}\\x1b[0m \\x1b[90m(${ex.id})\\x1b[0m`);\n console.log(` \\x1b[90mFramework:\\x1b[0m ${ex.framework}`);\n console.log(` \\x1b[90mDescription:\\x1b[0m ${ex.description}`);\n console.log(` \\x1b[90mCommand:\\x1b[0m \\x1b[36mnpx vibezcheck example ${ex.id}\\x1b[0m\\n`);\n });\n}\n\n/**\n * Scaffold selected example into target directory\n */\nexport async function scaffoldExample(exampleInput?: string, targetDirInput?: string): Promise<boolean> {\n const examplesBase = findExamplesDir();\n\n let selected = AVAILABLE_EXAMPLES.find(\n (e) => e.id.toLowerCase() === exampleInput?.toLowerCase()\n );\n\n // Check if numeric selection was entered (e.g. \"1\")\n if (!selected && exampleInput && !isNaN(Number(exampleInput))) {\n const idx = Number(exampleInput) - 1;\n if (idx >= 0 && idx < AVAILABLE_EXAMPLES.length) {\n selected = AVAILABLE_EXAMPLES[idx];\n }\n }\n\n // Interactive selection if not found or not provided\n if (!selected) {\n listExamples();\n const choice = await prompt('Select an example number (1-7) or name', '1');\n if (!choice) return false;\n\n if (!isNaN(Number(choice))) {\n const idx = Number(choice) - 1;\n selected = AVAILABLE_EXAMPLES[idx];\n } else {\n selected = AVAILABLE_EXAMPLES.find(\n (e) => e.id.toLowerCase() === choice.toLowerCase()\n );\n }\n\n if (!selected) {\n console.log(`\\x1b[31m✕ Unknown example selection: ${choice}\\x1b[0m`);\n return false;\n }\n }\n\n // Destination directory\n const defaultDir = selected.type === 'project' ? `./${selected.id}` : './';\n const targetDir = targetDirInput || (await prompt('Enter destination directory', defaultDir));\n const resolvedTarget = path.resolve(process.cwd(), targetDir);\n\n const sourcePath = path.join(examplesBase, selected.path);\n\n if (!fs.existsSync(sourcePath)) {\n console.log(`\\x1b[31m✕ Could not locate template files at: ${sourcePath}\\x1b[0m`);\n return false;\n }\n\n console.log(`\\n\\x1b[38;2;212;255;50m✦\\x1b[0m Creating \\x1b[1m${selected.name}\\x1b[0m in \\x1b[36m${path.relative(process.cwd(), resolvedTarget) || '.'}\\x1b[0m...`);\n\n if (selected.type === 'project') {\n copyDir(sourcePath, resolvedTarget);\n\n console.log(`\n\\x1b[32m✓ Successfully created ${selected.name}!\u001b[0m\n\n\\x1b[1mNext Steps:\\x1b[0m\n 1. \\x1b[33mcd ${path.relative(process.cwd(), resolvedTarget) || '.'}\\x1b[0m\n 2. \\x1b[33mpnpm install\\x1b[0m (or \\x1b[33mnpm install\\x1b[0m)\n 3. \\x1b[33mcp .env.example .env.local\\x1b[0m and add your API keys\n 4. \\x1b[33mpnpm dev\\x1b[0m to start the app\n`);\n } else {\n // Single file script\n fs.mkdirSync(resolvedTarget, { recursive: true });\n const destFile = path.join(resolvedTarget, path.basename(selected.path));\n fs.copyFileSync(sourcePath, destFile);\n\n console.log(`\n\\x1b[32m✓ Successfully saved ${path.basename(destFile)}!\u001b[0m\n\n\\x1b[1mTo run this example:\\x1b[0m\n \\x1b[33mnpx ts-node ${path.relative(process.cwd(), destFile)}\\x1b[0m\n`);\n }\n\n return true;\n}\n\n/**\n * Handler for CLI command: npx vibezcheck examples [name] [dir]\n */\nexport async function handleExamplesCommand(args: string[]): Promise<void> {\n // If user passed --list or -l\n if (args.includes('--list') || args.includes('-l')) {\n listExamples();\n return;\n }\n\n const exampleParam = args[0] && !args[0].startsWith('-') ? args[0] : undefined;\n const targetDirParam = args[1] && !args[1].startsWith('-') ? args[1] : undefined;\n\n await scaffoldExample(exampleParam, targetDirParam);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAAA,aAAe;AACf,IAAAC,eAAiB;AACjB,IAAAC,mBAAqB;;;ACGd,IAAM,sBAAyD;AAAA;AAAA,EAEpE,eAAe,EAAE,YAAY,GAAK,aAAa,IAAM,kBAAkB,IAAI;AAAA,EAC3E,iBAAiB,EAAE,YAAY,GAAK,aAAa,IAAM,kBAAkB,IAAI;AAAA,EAC7E,gBAAgB,EAAE,YAAY,KAAK,aAAa,KAAK,kBAAkB,KAAK;AAAA,EAC5E,SAAS,EAAE,YAAY,GAAK,aAAa,IAAM,kBAAkB,IAAI;AAAA,EACrE,cAAc,EAAE,YAAY,K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EACL,KAAK;AACH,iBAAa;AACb;AAAA,EACF,KAAK;AAAA,EACL,KAAK;AACH,iBAAa;AACb;AAAA,EACF;AACE,YAAQ,IAAI;AAAA,2BACW,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAQjC;AACG;AACJ;","names":["import_fs","import_path","import_readline","path","fs","readline","import_fs","import_path","import_readline","path","fs","readline","args","path","fs","prompt","readline"]}
|
package/dist/cli/index.mjs
CHANGED
|
@@ -46,6 +46,10 @@ var MODEL_PRICING_TABLE = {
|
|
|
46
46
|
"text-embedding-3-large": { inputPer1M: 0.13, outputPer1M: 0 },
|
|
47
47
|
"text-embedding-ada-002": { inputPer1M: 0.1, outputPer1M: 0 },
|
|
48
48
|
// --- Anthropic (Modern & Extended Thinking) ---
|
|
49
|
+
"claude-haiku-5.5": { inputPer1M: 0.1, outputPer1M: 0.5, cachedInputPer1M: 0.01 },
|
|
50
|
+
"claude-sonnet-5.5": { inputPer1M: 2, outputPer1M: 10, cachedInputPer1M: 0.1 },
|
|
51
|
+
"claude-opus-5.5": { inputPer1M: 4, outputPer1M: 20, cachedInputPer1M: 0.2 },
|
|
52
|
+
"claude-opus-5.5-fast": { inputPer1M: 8, outputPer1M: 40, cachedInputPer1M: 0.4 },
|
|
49
53
|
"claude-3-7-sonnet": { inputPer1M: 0.59, outputPer1M: 2.93, cachedInputPer1M: 0.3 },
|
|
50
54
|
"claude-sonnet-5": { inputPer1M: 2, outputPer1M: 10, cachedInputPer1M: 0.3 },
|
|
51
55
|
"claude-3-5-sonnet": { inputPer1M: 3, outputPer1M: 15, cachedInputPer1M: 0.3 },
|
|
@@ -60,6 +64,8 @@ var MODEL_PRICING_TABLE = {
|
|
|
60
64
|
"claude-2.0": { inputPer1M: 8, outputPer1M: 24 },
|
|
61
65
|
"claude-instant-1.2": { inputPer1M: 1.63, outputPer1M: 5.51 },
|
|
62
66
|
// --- Google Gemini (Modern & Thoughts) ---
|
|
67
|
+
"gemini-3.8-flash": { inputPer1M: 0.75, outputPer1M: 3.75, cachedInputPer1M: 0.075 },
|
|
68
|
+
"gemini-nano-banana-2.1": { inputPer1M: 1.5, outputPer1M: 7.5, cachedInputPer1M: 0.15 },
|
|
63
69
|
"gemini-3.7-flash": { inputPer1M: 0.75, outputPer1M: 3.75, cachedInputPer1M: 0.18 },
|
|
64
70
|
"gemini-3.1-pro": { inputPer1M: 2, outputPer1M: 12, cachedInputPer1M: 0.5 },
|
|
65
71
|
"gemini-3.5-flash": { inputPer1M: 1.5, outputPer1M: 9, cachedInputPer1M: 0.38 },
|
|
@@ -82,6 +88,7 @@ var MODEL_PRICING_TABLE = {
|
|
|
82
88
|
"grok-2-vision": { inputPer1M: 2, outputPer1M: 10 },
|
|
83
89
|
"grok-beta": { inputPer1M: 5, outputPer1M: 15 },
|
|
84
90
|
// --- Mistral ---
|
|
91
|
+
"mistral-large-4": { inputPer1M: 0.68, outputPer1M: 2.09, cachedInputPer1M: 0.07 },
|
|
85
92
|
"mistral-large-3": { inputPer1M: 2, outputPer1M: 6 },
|
|
86
93
|
"mistral-large-latest": { inputPer1M: 2, outputPer1M: 6 },
|
|
87
94
|
"mistral-large-2411": { inputPer1M: 2, outputPer1M: 6 },
|
|
@@ -646,7 +653,7 @@ function getCliVersion() {
|
|
|
646
653
|
}
|
|
647
654
|
} catch {
|
|
648
655
|
}
|
|
649
|
-
return "0.5.
|
|
656
|
+
return "0.5.13";
|
|
650
657
|
}
|
|
651
658
|
function printBanner() {
|
|
652
659
|
console.log(`
|