-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprompt.ts
More file actions
45 lines (33 loc) · 1.57 KB
/
prompt.ts
File metadata and controls
45 lines (33 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const MAX_CHARS = 50000;
export function buildPrompt(diffData: unknown): string {
// Truncate large diff data to avoid token limits (~50k chars)
let diffStr = JSON.stringify(diffData, null, 2);
if (diffStr.length > MAX_CHARS) {
diffStr = diffStr.substring(0, MAX_CHARS) + '\n... (truncated due to size)';
}
return `You are a senior frontend performance engineer. Analyze the Rsdoctor bundle-diff JSON below (baseline → current) and produce a concise GitHub PR comment in Markdown.
## Output format
### 📊 Size Changes
| Asset / Chunk | Baseline | Current | Δ Size | Δ % | Initial? |
|---|---|---|---|---|---|
(Only list entries with **>5 % or >10 KB** increase. If none, write "No significant regressions detected 🎉".)
### 🔍 Root Cause Analysis
- Bullet points: which modules / dependencies drove each regression.
### ⚠️ Risk Assessment
Overall severity: **Low / Medium / High**
- One-sentence justification focusing on initial-chunk impact and total size delta.
### 💡 Optimization Suggestions
- Numbered, actionable steps (e.g. code-split, tree-shake, replace heavy deps).
## Priority rules
1. Initial / entry chunks > async chunks > static assets.
2. Newly added large modules or duplicate dependencies deserve explicit callout.
3. If total bundle size *decreased*, highlight the wins instead.
## Constraints
- Be concise — aim for <400 words.
- Use exact numbers from the data; do not fabricate figures.
- If the diff data is empty or shows no meaningful change, state that clearly and skip the table.
Bundle diff data:
\`\`\`json
${diffStr}
\`\`\``;
}