debug-control.js 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. const fs = require('fs');
  2. const filePath = 'temp/rich-outline-fail_57_1779023037497.txt';
  3. const content = fs.readFileSync(filePath, 'utf-8');
  4. const marker = '========== AI 原始响应 ';
  5. const markerIdx = content.indexOf(marker);
  6. const headerEndIdx = content.indexOf(' ==========', markerIdx);
  7. const aiStart = content.indexOf('\n', headerEndIdx) + 1;
  8. const aiEnd = content.indexOf('\n\n', aiStart);
  9. const aiResponse = content.substring(aiStart, aiEnd);
  10. console.log('AI response length:', aiResponse.length);
  11. // Find all problematic characters (control chars except newlines/tabs/cr)
  12. for (let i = 0; i < aiResponse.length; i++) {
  13. const code = aiResponse.charCodeAt(i);
  14. if (code < 32 && code !== 10 && code !== 13 && code !== 9) {
  15. console.log('Control char at', i, ': code', code, 'hex', code.toString(16));
  16. }
  17. }
  18. // Check characters around 4070-4080
  19. console.log('\nChars around 4070-4090:');
  20. for (let i = 4070; i < 4090; i++) {
  21. const code = aiResponse.charCodeAt(i);
  22. const ch = aiResponse[i];
  23. console.log('pos', i, ': code=', code, 'char=', JSON.stringify(ch));
  24. }
  25. // Check if there's an issue with the content structure
  26. // Position 4074 is },{
  27. const ctx = aiResponse.substring(4040, 4120);
  28. console.log('\nContext 4040-4120:', JSON.stringify(ctx));