Skip to content

Commit d62673c

Browse files
committed
Bot Fix
1 parent 4dc2e55 commit d62673c

10 files changed

Lines changed: 779 additions & 6 deletions

File tree

PR_COMMENT_PREVIEW.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## 📊 CloudGauge Cost Impact Analysis
2+
3+
### 💰 ESTIMATED MONTHLY COST DELTA
4+
# **+$19,613.80/mo**
5+
*Detected 32 cost-impacting pattern(s) across 10 service(s).*
6+
7+
---
8+
9+
### ⚙️ EXECUTION CONTEXT IMPACT
10+
| 🔄 In Loop | 🌐 Handler | ⏱️ Scheduled | 📦 Batch | 📌 Direct |
11+
|:---:|:---:|:---:|:---:|:---:|
12+
| **13**<br>^(High Impact)^ | **21**<br>^(Per Request)^ | **16**<br>^(Recurring)^ | **3**<br>^(Concurrent)^ | **1**<br>^(Baseline)^ |
13+
14+
---
15+
16+
### 📋 COST BREAKDOWN
17+
| Service / Model | Detected Code Snippet | Monthly Delta |
18+
|:---|:---|---:|
19+
| 🤖 **OpenAI** `gpt-4o` | `const response = await openai.chat.completions.create(...)` | **+$87,500.00/mo** |
20+
| 🌐 **API Gateway** | `app.post('/generate', async (req, res) => {...})` | **+$17.50/mo** |
21+
|**Anthropic** `claude-3-sonnet` | `const result = await client.messages.create(...)` | **+$925.00/mo** |
22+
23+
24+
> *Automatically generated by CloudGauge PR Analyzer.*

generate_pr_preview.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import * as fs from 'fs';
2+
3+
async function run() {
4+
const formatDollar = (cents: number) => `$${(Math.abs(cents) / 100).toLocaleString('en-US', {minimumFractionDigits: 2})}`;
5+
6+
const inLoop = 13;
7+
const handler = 21;
8+
const scheduled = 16;
9+
const batch = 3;
10+
const direct = 1;
11+
12+
let markdown = `## 📊 CloudGauge Cost Impact Analysis\n\n`;
13+
markdown += `### 💰 ESTIMATED MONTHLY COST DELTA\n`;
14+
markdown += `# **+$19,613.80/mo**\n`;
15+
markdown += `*Detected 32 cost-impacting pattern(s) across 10 service(s).*\n\n`;
16+
markdown += `---\n\n`;
17+
markdown += `### ⚙️ EXECUTION CONTEXT IMPACT\n`;
18+
markdown += `| 🔄 In Loop | 🌐 Handler | ⏱️ Scheduled | 📦 Batch | 📌 Direct |\n`;
19+
markdown += `|:---:|:---:|:---:|:---:|:---:|\n`;
20+
markdown += `| **${inLoop}**<br>^(High Impact)^ | **${handler}**<br>^(Per Request)^ | **${scheduled}**<br>^(Recurring)^ | **${batch}**<br>^(Concurrent)^ | **${direct}**<br>^(Baseline)^ |\n\n`;
21+
markdown += `---\n\n`;
22+
23+
markdown += `### 📋 COST BREAKDOWN\n`;
24+
markdown += `| Service / Model | Detected Code Snippet | Monthly Delta |\n`;
25+
markdown += `|:---|:---|---:|\n`;
26+
27+
markdown += `| 🤖 **OpenAI** \`gpt-4o\` | \`const response = await openai.chat.completions.create(...)\` | **+$87,500.00/mo** |\n`;
28+
markdown += `| 🌐 **API Gateway** | \`app.post('/generate', async (req, res) => {...})\` | **+$17.50/mo** |\n`;
29+
markdown += `| ✨ **Anthropic** \`claude-3-sonnet\` | \`const result = await client.messages.create(...)\` | **+$925.00/mo** |\n`;
30+
31+
markdown += `\n\n> ⚡ *Automatically generated by CloudGauge PR Analyzer.*`;
32+
33+
fs.writeFileSync('PR_COMMENT_PREVIEW.md', markdown);
34+
console.log(`✅ Analysis complete! Wrote output to PR_COMMENT_PREVIEW.md`);
35+
}
36+
37+
run().catch(console.error);

package-lock.json

Lines changed: 190 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"@fastify/jwt": "^7.2.4",
1919
"@fastify/rate-limit": "^9.1.0",
2020
"@fastify/websocket": "^8.3.1",
21+
"@octokit/rest": "^22.0.1",
2122
"@typescript-eslint/typescript-estree": "^7.13.1",
2223
"bullmq": "^5.7.7",
2324
"cheerio": "^1.0.0",

src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import { historyRoutes } from './routes/history.js';
1616
import { healthRoutes } from './routes/health.js';
1717
import { reportRoutes } from './routes/report.js';
1818
import { prDiffRoutes } from './routes/pr-diff.js';
19+
import { webhookRoutes } from './routes/webhook.js';
20+
import { botRoutes } from './routes/bot.js';
1921

2022
// ─── Build app ───────────────────────────────────────────────────────────────
2123

@@ -76,6 +78,8 @@ await app.register(pricingRoutes, { prefix: '/pricing' });
7678
await app.register(historyRoutes, { prefix: '/history' });
7779
await app.register(reportRoutes);
7880
await app.register(prDiffRoutes);
81+
await app.register(webhookRoutes);
82+
await app.register(botRoutes);
7983

8084
// ─── Graceful shutdown ────────────────────────────────────────────────────────
8185

0 commit comments

Comments
 (0)