Skip to content

Commit d546566

Browse files
committed
feat: Enhance XML escaping in metadata and project structure for improved safety
1 parent e069e0b commit d546566

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

index.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,21 +1490,25 @@
14901490
parts.push('<codebase_context>\n\n');
14911491

14921492
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`);
14961496
parts.push(` <statistics>\n`);
14971497
parts.push(` <total_files>${totalFiles}</total_files>\n`);
14981498
parts.push(` <total_size>${bytes(totalSize)}</total_size>\n`);
14991499
parts.push(` <estimated_tokens>${estimatedTokens}</estimated_tokens>\n`);
15001500
parts.push(` </statistics>\n`);
15011501
parts.push(` <languages>\n`);
15021502
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`);
15041504
});
15051505
parts.push(` </languages>\n`);
15061506
parts.push('</metadata>\n\n');
15071507

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');
15081512
parts.push('<system_prompt>\n');
15091513
parts.push(' <role>Expert Software Engineer</role>\n');
15101514
parts.push(' <task>Analyze and work with this complete codebase</task>\n');
@@ -1524,7 +1528,7 @@
15241528
parts.push(' </data_format>\n');
15251529
parts.push('</system_prompt>\n\n');
15261530

1527-
parts.push('<project_structure>\n', struct, '</project_structure>\n\n');
1531+
parts.push('<project_structure><![CDATA[' + struct + ']]></project_structure>\n\n');
15281532
parts.push('<source_files>\n');
15291533
} else if (S.model === 'gemini') {
15301534
parts.push('# 🚀 COMPLETE PROJECT CONTEXT FOR GEMINI\n');
@@ -1547,7 +1551,8 @@
15471551
});
15481552
parts.push('\n');
15491553

1550-
parts.push('## 🧠 SYSTEM PROMPT & INSTRUCTIONS\n\n');
1554+
// Use unified human-readable header for Gemini output
1555+
parts.push('## 🎯 SYSTEM PROMPT\n');
15511556
parts.push('> **Role**: Expert Software Engineer and Code Analyst\n\n');
15521557
parts.push('**📌 Key Instructions:**\n\n');
15531558
parts.push('1. **Complete Context**: This is the FULL and AUTHORITATIVE codebase\n');

style.css

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,23 @@
44
color: #e8e8e8;
55
border: 1px solid #444;
66
border-radius: 4px;
7-
padding: 2px 8px;
8-
font-size: 1em;
7+
padding: 6px 34px 6px 10px;
8+
font-size: 0.95em;
99
margin-left: 4px;
1010
margin-right: 2px;
1111
outline: none;
12-
transition: border 0.15s;
12+
transition: border 0.15s, box-shadow 0.15s;
13+
appearance: none;
14+
-webkit-appearance: none;
15+
-moz-appearance: none;
16+
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="6"><path fill="%23e8e8e8" d="M0 0 L5 6 L10 0 Z"/></svg>');
17+
background-repeat: no-repeat;
18+
background-position: right 8px center;
19+
background-size: 10px 6px;
1320
}
1421
#modelSelector:focus {
1522
border-color: #fbbf24;
23+
box-shadow: 0 0 0 3px rgba(251,187,36,0.08);
1624
}
1725
/* Only sidebar main action icons (Select Directory, Create Context) black and small */
1826
.sidebar-btn-icon {

0 commit comments

Comments
 (0)