|
1194 | 1194 | const parts = []; |
1195 | 1195 | // === AI Model Template Logic === |
1196 | 1196 | if (S.model === 'gpt') { |
1197 | | - parts.push('### GPT-4 CONTEXT TEMPLATE\n'); |
| 1197 | + parts.push('# Project Context for GPT-4\n\n'); |
| 1198 | + parts.push('## Instructions\n'); |
| 1199 | + parts.push('You are being provided with a complete codebase context. Please:\n'); |
| 1200 | + parts.push('- Analyze the code structure and architecture\n'); |
| 1201 | + parts.push('- Understand dependencies between files\n'); |
| 1202 | + parts.push('- Maintain consistency with existing code patterns\n'); |
| 1203 | + parts.push('- Reference specific files when answering questions\n\n'); |
| 1204 | + parts.push('## Project Structure\n```\n', struct, '```\n\n'); |
| 1205 | + parts.push('## Source Files\n\n'); |
1198 | 1206 | } else if (S.model === 'claude') { |
1199 | | - parts.push('### CLAUDE CONTEXT TEMPLATE\n'); |
| 1207 | + parts.push('# Codebase Context for Claude\n\n'); |
| 1208 | + parts.push('<context>\n'); |
| 1209 | + parts.push('<purpose>\n'); |
| 1210 | + parts.push('This is a complete project codebase provided for analysis, code review, or implementation tasks.\n'); |
| 1211 | + parts.push('Please analyze the architecture, patterns, and maintain consistency when making changes.\n'); |
| 1212 | + parts.push('</purpose>\n\n'); |
| 1213 | + parts.push('<project_structure>\n', struct, '</project_structure>\n\n'); |
| 1214 | + parts.push('<source_files>\n'); |
1200 | 1215 | } else if (S.model === 'gemini') { |
1201 | | - parts.push('### GEMINI CONTEXT TEMPLATE\n'); |
| 1216 | + parts.push('# Complete Project Context for Gemini\n\n'); |
| 1217 | + parts.push('## Overview\n'); |
| 1218 | + parts.push('Complete codebase with file structure and contents for analysis and development tasks.\n\n'); |
| 1219 | + parts.push('## Directory Structure\n```\n', struct, '```\n\n'); |
| 1220 | + parts.push('## File Contents\n\n'); |
1202 | 1221 | } |
1203 | | - parts.push('<folder-structure>\n', struct, '</folder-structure>\n'); |
1204 | 1222 | // Binary files are intentionally excluded from the generated output (they remain visible in the tree) |
1205 | 1223 | // Build document sections faster - no UI updates during build |
1206 | 1224 | contents.forEach(({ path, content }) => { |
1207 | 1225 | const full = getFullPath(path); |
1208 | | - parts.push(`=== FILE: ${full} ===\n`); |
1209 | | - parts.push(`<document path=\"${path}\">\n`, content, '\n</document>\n'); |
| 1226 | + const ext = path.split('.').pop().toLowerCase(); |
| 1227 | + |
| 1228 | + if (S.model === 'gpt') { |
| 1229 | + // GPT-4 format: Clear markdown with code blocks |
| 1230 | + parts.push(`### ${full}\n`); |
| 1231 | + parts.push('```', ext, '\n', content, '\n```\n\n'); |
| 1232 | + } else if (S.model === 'claude') { |
| 1233 | + // Claude format: XML-style with clear metadata |
| 1234 | + parts.push(`<file path="${full}">\n`); |
| 1235 | + parts.push(`<language>${ext}</language>\n`); |
| 1236 | + parts.push(`<content>\n${content}\n</content>\n`); |
| 1237 | + parts.push('</file>\n\n'); |
| 1238 | + } else if (S.model === 'gemini') { |
| 1239 | + // Gemini format: Structured with clear delimiters |
| 1240 | + parts.push(`## File: ${full}\n`); |
| 1241 | + parts.push(`**Language:** ${ext}\n\n`); |
| 1242 | + parts.push('```', ext, '\n', content, '\n```\n\n'); |
| 1243 | + } |
1210 | 1244 | }); |
| 1245 | + |
| 1246 | + // Add closing tags for Claude |
| 1247 | + if (S.model === 'claude') { |
| 1248 | + parts.push('</source_files>\n</context>\n'); |
| 1249 | + } |
1211 | 1250 |
|
1212 | 1251 | let ctx; |
1213 | 1252 | try { |
|
1256 | 1295 |
|
1257 | 1296 | const genAndDL = async (struct, textFiles, binaryFiles) => { |
1258 | 1297 | const parts = []; |
1259 | | - parts.push('<folder-structure>\n', struct, '</folder-structure>\n'); |
| 1298 | + |
| 1299 | + // Add model-specific headers for download |
| 1300 | + if (S.model === 'gpt') { |
| 1301 | + parts.push('# Project Context for GPT-4\n\n'); |
| 1302 | + parts.push('## Instructions\n'); |
| 1303 | + parts.push('You are being provided with a complete codebase context. Please:\n'); |
| 1304 | + parts.push('- Analyze the code structure and architecture\n'); |
| 1305 | + parts.push('- Understand dependencies between files\n'); |
| 1306 | + parts.push('- Maintain consistency with existing code patterns\n'); |
| 1307 | + parts.push('- Reference specific files when answering questions\n\n'); |
| 1308 | + parts.push('## Project Structure\n```\n', struct, '```\n\n'); |
| 1309 | + parts.push('## Source Files\n\n'); |
| 1310 | + } else if (S.model === 'claude') { |
| 1311 | + parts.push('# Codebase Context for Claude\n\n'); |
| 1312 | + parts.push('<context>\n'); |
| 1313 | + parts.push('<purpose>\n'); |
| 1314 | + parts.push('This is a complete project codebase provided for analysis, code review, or implementation tasks.\n'); |
| 1315 | + parts.push('Please analyze the architecture, patterns, and maintain consistency when making changes.\n'); |
| 1316 | + parts.push('</purpose>\n\n'); |
| 1317 | + parts.push('<project_structure>\n', struct, '</project_structure>\n\n'); |
| 1318 | + parts.push('<source_files>\n'); |
| 1319 | + } else if (S.model === 'gemini') { |
| 1320 | + parts.push('# Complete Project Context for Gemini\n\n'); |
| 1321 | + parts.push('## Overview\n'); |
| 1322 | + parts.push('Complete codebase with file structure and contents for analysis and development tasks.\n\n'); |
| 1323 | + parts.push('## Directory Structure\n```\n', struct, '```\n\n'); |
| 1324 | + parts.push('## File Contents\n\n'); |
| 1325 | + } |
1260 | 1326 |
|
1261 | 1327 | let done = 0; |
1262 | 1328 | const FAST_BATCH = 100; |
|
1292 | 1358 | return; |
1293 | 1359 | } |
1294 | 1360 |
|
1295 | | - parts.push('=== FILE: ' + getFullPath(p) + ' ===\n'); |
1296 | | - parts.push('<document path="' + p + '">\n', content, '\n</document>\n'); |
| 1361 | + // Format based on selected AI model |
| 1362 | + const full = getFullPath(p); |
| 1363 | + const ext = p.split('.').pop().toLowerCase(); |
| 1364 | + |
| 1365 | + if (S.model === 'gpt') { |
| 1366 | + parts.push(`### ${full}\n`); |
| 1367 | + parts.push('```', ext, '\n', content, '\n```\n\n'); |
| 1368 | + } else if (S.model === 'claude') { |
| 1369 | + parts.push(`<file path="${full}">\n`); |
| 1370 | + parts.push(`<language>${ext}</language>\n`); |
| 1371 | + parts.push(`<content>\n${content}\n</content>\n`); |
| 1372 | + parts.push('</file>\n\n'); |
| 1373 | + } else if (S.model === 'gemini') { |
| 1374 | + parts.push(`## File: ${full}\n`); |
| 1375 | + parts.push(`**Language:** ${ext}\n\n`); |
| 1376 | + parts.push('```', ext, '\n', content, '\n```\n\n'); |
| 1377 | + } |
1297 | 1378 |
|
1298 | 1379 | const sFileIndex = S.files.findIndex(sf => sf.path === p); |
1299 | 1380 | if (sFileIndex !== -1) { |
|
0 commit comments