Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions PR_COMMENT_PREVIEW.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## 📊 CloudGauge Cost Impact Analysis

### 💰 ESTIMATED MONTHLY COST DELTA
# **+$19,613.80/mo**
*Detected 32 cost-impacting pattern(s) across 10 service(s).*

---

### ⚙️ EXECUTION CONTEXT IMPACT
| 🔄 In Loop | 🌐 Handler | ⏱️ Scheduled | 📦 Batch | 📌 Direct |
|:---:|:---:|:---:|:---:|:---:|
| **13**<br>^(High Impact)^ | **21**<br>^(Per Request)^ | **16**<br>^(Recurring)^ | **3**<br>^(Concurrent)^ | **1**<br>^(Baseline)^ |

---

### 📋 COST BREAKDOWN
| Service / Model | Detected Code Snippet | Monthly Delta |
|:---|:---|---:|
| 🤖 **OpenAI** `gpt-4o` | `const response = await openai.chat.completions.create(...)` | **+$87,500.00/mo** |
| 🌐 **API Gateway** | `app.post('/generate', async (req, res) => {...})` | **+$17.50/mo** |
| ✨ **Anthropic** `claude-3-sonnet` | `const result = await client.messages.create(...)` | **+$925.00/mo** |


> ⚡ *Automatically generated by CloudGauge PR Analyzer.*
37 changes: 37 additions & 0 deletions generate_pr_preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import * as fs from 'fs';

async function run() {
const formatDollar = (cents: number) => `$${(Math.abs(cents) / 100).toLocaleString('en-US', {minimumFractionDigits: 2})}`;

const inLoop = 13;
const handler = 21;
const scheduled = 16;
const batch = 3;
const direct = 1;

let markdown = `## 📊 CloudGauge Cost Impact Analysis\n\n`;
markdown += `### 💰 ESTIMATED MONTHLY COST DELTA\n`;
markdown += `# **+$19,613.80/mo**\n`;
markdown += `*Detected 32 cost-impacting pattern(s) across 10 service(s).*\n\n`;
markdown += `---\n\n`;
markdown += `### ⚙️ EXECUTION CONTEXT IMPACT\n`;
markdown += `| 🔄 In Loop | 🌐 Handler | ⏱️ Scheduled | 📦 Batch | 📌 Direct |\n`;
markdown += `|:---:|:---:|:---:|:---:|:---:|\n`;
markdown += `| **${inLoop}**<br>^(High Impact)^ | **${handler}**<br>^(Per Request)^ | **${scheduled}**<br>^(Recurring)^ | **${batch}**<br>^(Concurrent)^ | **${direct}**<br>^(Baseline)^ |\n\n`;
markdown += `---\n\n`;

markdown += `### 📋 COST BREAKDOWN\n`;
markdown += `| Service / Model | Detected Code Snippet | Monthly Delta |\n`;
markdown += `|:---|:---|---:|\n`;

markdown += `| 🤖 **OpenAI** \`gpt-4o\` | \`const response = await openai.chat.completions.create(...)\` | **+$87,500.00/mo** |\n`;
markdown += `| 🌐 **API Gateway** | \`app.post('/generate', async (req, res) => {...})\` | **+$17.50/mo** |\n`;
markdown += `| ✨ **Anthropic** \`claude-3-sonnet\` | \`const result = await client.messages.create(...)\` | **+$925.00/mo** |\n`;

markdown += `\n\n> ⚡ *Automatically generated by CloudGauge PR Analyzer.*`;

fs.writeFileSync('PR_COMMENT_PREVIEW.md', markdown);
console.log(`✅ Analysis complete! Wrote output to PR_COMMENT_PREVIEW.md`);
}

run().catch(console.error);
190 changes: 190 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@fastify/jwt": "^7.2.4",
"@fastify/rate-limit": "^9.1.0",
"@fastify/websocket": "^8.3.1",
"@octokit/rest": "^22.0.1",
"@typescript-eslint/typescript-estree": "^7.13.1",
"bullmq": "^5.7.7",
"cheerio": "^1.0.0",
Expand Down
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { historyRoutes } from './routes/history.js';
import { healthRoutes } from './routes/health.js';
import { reportRoutes } from './routes/report.js';
import { prDiffRoutes } from './routes/pr-diff.js';
import { webhookRoutes } from './routes/webhook.js';
import { botRoutes } from './routes/bot.js';

// ─── Build app ───────────────────────────────────────────────────────────────

Expand Down Expand Up @@ -76,6 +78,8 @@ await app.register(pricingRoutes, { prefix: '/pricing' });
await app.register(historyRoutes, { prefix: '/history' });
await app.register(reportRoutes);
await app.register(prDiffRoutes);
await app.register(webhookRoutes);
await app.register(botRoutes);

// ─── Graceful shutdown ────────────────────────────────────────────────────────

Expand Down
Loading
Loading