Skip to content

Commit f1cc16e

Browse files
committed
feat: Add custom system prompt for enhanced code analysis instructions
1 parent d546566 commit f1cc16e

File tree

1 file changed

+48
-66
lines changed

1 file changed

+48
-66
lines changed

index.js

Lines changed: 48 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -955,8 +955,49 @@
955955
.replace(/\"/g, '"')
956956
.replace(/'/g, ''');
957957

958-
// XML-specific escape (alias for clarity)
959-
const xmlEscape = esc;
958+
// XML-specific escape (alias for clarity)
959+
const xmlEscape = esc;
960+
961+
const CUSTOM_SYSTEM_PROMPT = `why cant you understand my words
962+
You are a senior software engineer assisting with a single-file codebase.
963+
Your task: read the provided file/snippet, understand the user request, and produce safe, minimal, high-quality changes.
964+
965+
Rules:
966+
1. Priorities:
967+
a) Correctness and safety
968+
b) Minimal, targeted diff
969+
c) Maintainability and clarity
970+
d) Tests when relevant
971+
972+
2. For every task, output in this order:
973+
DIAGNOSIS
974+
PATCH (unified diff or full replacement if required)
975+
TESTS (only if meaningful)
976+
VERIFY STEPS (commands + expected result)
977+
COMMIT/PR (one-line commit + short PR description)
978+
NOTES (optional, very brief)
979+
980+
3. Patch guidelines:
981+
- Keep behavior backward-compatible unless user requests otherwise.
982+
- Do not introduce unnecessary refactors or unrelated improvements.
983+
- Use idiomatic, modern patterns for the project’s main language.
984+
- Keep changes small and self-contained.
985+
- Comment only for non-obvious logic.
986+
987+
4. Assumptions:
988+
- Treat the provided file as the full context unless stated.
989+
- If constraints or missing details exist, state assumptions clearly.
990+
- Only add files (e.g., tests) when justified.
991+
992+
5. Testing:
993+
- Provide minimal unit/integration tests that demonstrate correctness.
994+
- Use the language’s standard test framework when obvious.
995+
996+
6. Communication style:
997+
- Concise, technical, code-first.
998+
- No chit-chat, no emotional language.
999+
1000+
Your goal: deliver precise, production-grade patches with the smallest necessary changes, clear reasoning, and verifiable steps.`;
9601001
// ============================================================================
9611002
// CUSTOM MODAL - NO ALERTS
9621003
// ============================================================================
@@ -1467,19 +1508,7 @@
14671508

14681509
parts.push('## 🎯 SYSTEM PROMPT\n');
14691510
parts.push('```\n');
1470-
parts.push('You are an expert software engineer analyzing a complete codebase.\n\n');
1471-
parts.push('INSTRUCTIONS:\n');
1472-
parts.push('- Treat this as the COMPLETE and AUTHORITATIVE source of truth for this project\n');
1473-
parts.push('- Analyze the code structure, architecture, and design patterns\n');
1474-
parts.push('- Understand dependencies and relationships between files\n');
1475-
parts.push('- Maintain consistency with existing code patterns and conventions\n');
1476-
parts.push('- Always reference specific file paths when discussing code\n');
1477-
parts.push('- Consider the project holistically before making suggestions\n');
1478-
parts.push('- Respect the established coding style and naming conventions\n\n');
1479-
parts.push('DATA FORMAT:\n');
1480-
parts.push('- Each file is presented with its full path and language\n');
1481-
parts.push('- Code blocks use appropriate syntax highlighting\n');
1482-
parts.push('- The project structure is provided first for context\n');
1511+
parts.push(CUSTOM_SYSTEM_PROMPT + '\n');
14831512
parts.push('```\n\n');
14841513

14851514
parts.push('## 📁 PROJECT STRUCTURE\n```\n', struct, '```\n\n');
@@ -1505,27 +1534,9 @@
15051534
parts.push(` </languages>\n`);
15061535
parts.push('</metadata>\n\n');
15071536

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
15111537
parts.push('<!-- 🎯 SYSTEM PROMPT -->\n');
15121538
parts.push('<system_prompt>\n');
1513-
parts.push(' <role>Expert Software Engineer</role>\n');
1514-
parts.push(' <task>Analyze and work with this complete codebase</task>\n');
1515-
parts.push(' <instructions>\n');
1516-
parts.push(' - This is the COMPLETE and AUTHORITATIVE codebase\n');
1517-
parts.push(' - Analyze architecture, patterns, and code organization\n');
1518-
parts.push(' - Understand file dependencies and relationships\n');
1519-
parts.push(' - Maintain existing code style and conventions\n');
1520-
parts.push(' - Reference specific file paths in your responses\n');
1521-
parts.push(' - Think holistically about the entire project\n');
1522-
parts.push(' - Respect established patterns and best practices\n');
1523-
parts.push(' </instructions>\n');
1524-
parts.push(' <data_format>\n');
1525-
parts.push(' - Files are in XML format with path and language metadata\n');
1526-
parts.push(' - Project structure provided first for navigation\n');
1527-
parts.push(' - All file contents are complete and unmodified\n');
1528-
parts.push(' </data_format>\n');
1539+
parts.push('<![CDATA[' + CUSTOM_SYSTEM_PROMPT + ']]>\n');
15291540
parts.push('</system_prompt>\n\n');
15301541

15311542
parts.push('<project_structure><![CDATA[' + struct + ']]></project_structure>\n\n');
@@ -1553,8 +1564,6 @@
15531564

15541565
// Use unified human-readable header for Gemini output
15551566
parts.push('## 🎯 SYSTEM PROMPT\n');
1556-
parts.push('> **Role**: Expert Software Engineer and Code Analyst\n\n');
1557-
parts.push('**📌 Key Instructions:**\n\n');
15581567
parts.push('1. **Complete Context**: This is the FULL and AUTHORITATIVE codebase\n');
15591568
parts.push('2. **Analyze Thoroughly**: Understand architecture, patterns, and dependencies\n');
15601569
parts.push('3. **Maintain Consistency**: Follow existing code style and conventions\n');
@@ -1696,19 +1705,7 @@
16961705

16971706
parts.push('## 🎯 SYSTEM PROMPT\n');
16981707
parts.push('```\n');
1699-
parts.push('You are an expert software engineer analyzing a complete codebase.\n\n');
1700-
parts.push('INSTRUCTIONS:\n');
1701-
parts.push('- Treat this as the COMPLETE and AUTHORITATIVE source of truth for this project\n');
1702-
parts.push('- Analyze the code structure, architecture, and design patterns\n');
1703-
parts.push('- Understand dependencies and relationships between files\n');
1704-
parts.push('- Maintain consistency with existing code patterns and conventions\n');
1705-
parts.push('- Always reference specific file paths when discussing code\n');
1706-
parts.push('- Consider the project holistically before making suggestions\n');
1707-
parts.push('- Respect the established coding style and naming conventions\n\n');
1708-
parts.push('DATA FORMAT:\n');
1709-
parts.push('- Each file is presented with its full path and language\n');
1710-
parts.push('- Code blocks use appropriate syntax highlighting\n');
1711-
parts.push('- The project structure is provided first for context\n');
1708+
parts.push(CUSTOM_SYSTEM_PROMPT + '\n');
17121709
parts.push('```\n\n');
17131710

17141711
parts.push('## 📁 PROJECT STRUCTURE\n```\n', struct, '```\n\n');
@@ -1735,22 +1732,7 @@
17351732
parts.push('</metadata>\n\n');
17361733

17371734
parts.push('<system_prompt>\n');
1738-
parts.push(' <role>Expert Software Engineer</role>\n');
1739-
parts.push(' <task>Analyze and work with this complete codebase</task>\n');
1740-
parts.push(' <instructions>\n');
1741-
parts.push(' - This is the COMPLETE and AUTHORITATIVE codebase\n');
1742-
parts.push(' - Analyze architecture, patterns, and code organization\n');
1743-
parts.push(' - Understand file dependencies and relationships\n');
1744-
parts.push(' - Maintain existing code style and conventions\n');
1745-
parts.push(' - Reference specific file paths in your responses\n');
1746-
parts.push(' - Think holistically about the entire project\n');
1747-
parts.push(' - Respect established patterns and best practices\n');
1748-
parts.push(' </instructions>\n');
1749-
parts.push(' <data_format>\n');
1750-
parts.push(' - Files are in XML format with path and language metadata\n');
1751-
parts.push(' - Project structure provided first for navigation\n');
1752-
parts.push(' - All file contents are complete and unmodified\n');
1753-
parts.push(' </data_format>\n');
1735+
parts.push('<![CDATA[' + CUSTOM_SYSTEM_PROMPT + ']]>\n');
17541736
parts.push('</system_prompt>\n\n');
17551737

17561738
parts.push('<project_structure>\n', struct, '</project_structure>\n\n');
@@ -1776,7 +1758,7 @@
17761758
});
17771759
parts.push('\n');
17781760

1779-
parts.push('## 🧠 SYSTEM PROMPT & INSTRUCTIONS\n\n');
1761+
parts.push('## 🎯 SYSTEM PROMPT\n\n');
17801762
parts.push('> **Role**: Expert Software Engineer and Code Analyst\n\n');
17811763
parts.push('**📌 Key Instructions:**\n\n');
17821764
parts.push('1. **Complete Context**: This is the FULL and AUTHORITATIVE codebase\n');

0 commit comments

Comments
 (0)