|
1490 | 1490 | parts.push('<codebase_context>\n\n'); |
1491 | 1491 |
|
1492 | 1492 | parts.push('<metadata>\n'); |
1493 | | - parts.push(` <generated_at>${timestamp}</generated_at>\n`); |
1494 | | - parts.push(` <formatted_date>${formattedDate}</formatted_date>\n`); |
1495 | | - parts.push(` <project_root>${S.root}</project_root>\n`); |
| 1493 | + parts.push(` <generated_at>${xmlEscape(timestamp)}</generated_at>\n`); |
| 1494 | + parts.push(` <formatted_date>${xmlEscape(formattedDate)}</formatted_date>\n`); |
| 1495 | + parts.push(` <project_root>${xmlEscape(S.root)}</project_root>\n`); |
1496 | 1496 | parts.push(` <statistics>\n`); |
1497 | 1497 | parts.push(` <total_files>${totalFiles}</total_files>\n`); |
1498 | 1498 | parts.push(` <total_size>${bytes(totalSize)}</total_size>\n`); |
1499 | 1499 | parts.push(` <estimated_tokens>${estimatedTokens}</estimated_tokens>\n`); |
1500 | 1500 | parts.push(` </statistics>\n`); |
1501 | 1501 | parts.push(` <languages>\n`); |
1502 | 1502 | Object.entries(langStats).sort((a, b) => b[1] - a[1]).forEach(([lang, count]) => { |
1503 | | - parts.push(` <language name="${lang}" count="${count}" />\n`); |
| 1503 | + parts.push(` <language name="${xmlEscape(lang)}" count="${count}" />\n`); |
1504 | 1504 | }); |
1505 | 1505 | parts.push(` </languages>\n`); |
1506 | 1506 | parts.push('</metadata>\n\n'); |
1507 | 1507 |
|
| 1508 | + // Human-readable header (XML-safe comment) to mark the system prompt section |
| 1509 | + parts.push('<!-- 🎯 SYSTEM PROMPT -->\n'); |
| 1510 | + // Human-readable header (XML-safe comment) to mark the system prompt section |
| 1511 | + parts.push('<!-- 🎯 SYSTEM PROMPT -->\n'); |
1508 | 1512 | parts.push('<system_prompt>\n'); |
1509 | 1513 | parts.push(' <role>Expert Software Engineer</role>\n'); |
1510 | 1514 | parts.push(' <task>Analyze and work with this complete codebase</task>\n'); |
|
1524 | 1528 | parts.push(' </data_format>\n'); |
1525 | 1529 | parts.push('</system_prompt>\n\n'); |
1526 | 1530 |
|
1527 | | - parts.push('<project_structure>\n', struct, '</project_structure>\n\n'); |
| 1531 | + parts.push('<project_structure><![CDATA[' + struct + ']]></project_structure>\n\n'); |
1528 | 1532 | parts.push('<source_files>\n'); |
1529 | 1533 | } else if (S.model === 'gemini') { |
1530 | 1534 | parts.push('# 🚀 COMPLETE PROJECT CONTEXT FOR GEMINI\n'); |
|
1547 | 1551 | }); |
1548 | 1552 | parts.push('\n'); |
1549 | 1553 |
|
1550 | | - parts.push('## 🧠 SYSTEM PROMPT & INSTRUCTIONS\n\n'); |
| 1554 | + // Use unified human-readable header for Gemini output |
| 1555 | + parts.push('## 🎯 SYSTEM PROMPT\n'); |
1551 | 1556 | parts.push('> **Role**: Expert Software Engineer and Code Analyst\n\n'); |
1552 | 1557 | parts.push('**📌 Key Instructions:**\n\n'); |
1553 | 1558 | parts.push('1. **Complete Context**: This is the FULL and AUTHORITATIVE codebase\n'); |
|
0 commit comments