|
947 | 947 | cls: '' // No custom classes needed - icons are already colored |
948 | 948 | }; |
949 | 949 | }; |
950 | | - const esc = s => s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>'); |
| 950 | + // Escape text for HTML/XML contexts |
| 951 | + const esc = s => String(s) |
| 952 | + .replace(/&/g, '&') |
| 953 | + .replace(/</g, '<') |
| 954 | + .replace(/>/g, '>') |
| 955 | + .replace(/\"/g, '"') |
| 956 | + .replace(/'/g, '''); |
| 957 | + |
| 958 | + // XML-specific escape (alias for clarity) |
| 959 | + const xmlEscape = esc; |
951 | 960 | // ============================================================================ |
952 | 961 | // CUSTOM MODAL - NO ALERTS |
953 | 962 | // ============================================================================ |
|
1571 | 1580 | parts.push(`### ${full}\n`); |
1572 | 1581 | parts.push('```', ext, '\n', content, '\n```\n\n'); |
1573 | 1582 | } else if (S.model === 'claude') { |
1574 | | - // Claude format: XML-style with clear metadata |
1575 | | - parts.push(`<file path="${full}">\n`); |
1576 | | - parts.push(`<language>${ext}</language>\n`); |
1577 | | - parts.push(`<content>\n${content}\n</content>\n`); |
| 1583 | + // Claude format: XML-style with proper escaping |
| 1584 | + parts.push(`<file path="${xmlEscape(full)}">\n`); |
| 1585 | + parts.push(`<language>${xmlEscape(ext)}</language>\n`); |
| 1586 | + parts.push(`<content>\n${xmlEscape(content)}\n</content>\n`); |
1578 | 1587 | parts.push('</file>\n\n'); |
1579 | 1588 | } else if (S.model === 'gemini') { |
1580 | 1589 | // Gemini format: Structured with clear delimiters |
|
1584 | 1593 | } |
1585 | 1594 | }); |
1586 | 1595 |
|
1587 | | - // Add closing tags for Claude |
| 1596 | + // Add closing tags for Claude (match opening tag) |
1588 | 1597 | if (S.model === 'claude') { |
1589 | | - parts.push('</source_files>\n</context>\n'); |
| 1598 | + parts.push('</source_files>\n</codebase_context>\n'); |
1590 | 1599 | } |
1591 | 1600 |
|
1592 | 1601 | let ctx; |
|
1609 | 1618 | S.ctx = ctx; |
1610 | 1619 | S.isArray = false; |
1611 | 1620 |
|
| 1621 | + // Debugging: log generated output summary |
| 1622 | + try { |
| 1623 | + console.log('Generated context:', { model: S.model, size: ctx.length, preview: ctx.substring(0, 200) }); |
| 1624 | + } catch (e) { |
| 1625 | + console.log('Generated context (unable to preview):', { model: S.model }); |
| 1626 | + } |
| 1627 | + |
1612 | 1628 | if (isLarge) { |
1613 | 1629 | const prev = ctx.substring(0, 50000); |
1614 | 1630 | const rem = ctx.length - 50000; |
|
1820 | 1836 | parts.push(`### ${full}\n`); |
1821 | 1837 | parts.push('```', ext, '\n', content, '\n```\n\n'); |
1822 | 1838 | } else if (S.model === 'claude') { |
1823 | | - parts.push(`<file path="${full}">\n`); |
1824 | | - parts.push(`<language>${ext}</language>\n`); |
1825 | | - parts.push(`<content>\n${content}\n</content>\n`); |
| 1839 | + parts.push(`<file path="${xmlEscape(full)}">\n`); |
| 1840 | + parts.push(`<language>${xmlEscape(ext)}</language>\n`); |
| 1841 | + parts.push(`<content>\n${xmlEscape(content)}\n</content>\n`); |
1826 | 1842 | parts.push('</file>\n\n'); |
1827 | 1843 | } else if (S.model === 'gemini') { |
1828 | 1844 | parts.push(`## File: ${full}\n`); |
|
1852 | 1868 | } |
1853 | 1869 | } |
1854 | 1870 |
|
1855 | | - // Add closing tags for Claude format |
| 1871 | + // Add closing tags for Claude format (match opening tag) |
1856 | 1872 | if (S.model === 'claude') { |
1857 | | - parts.push('</source_files>\n</context>\n'); |
| 1873 | + parts.push('</source_files>\n</codebase_context>\n'); |
1858 | 1874 | } |
1859 | 1875 |
|
1860 | 1876 | await new Promise(r => setTimeout(r, 0)); |
|
0 commit comments