debug-parse6.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. const fs = require('fs');
  2. const content = fs.readFileSync('temp/rich-outline-fail_57_1779014691106.txt', 'utf-8');
  3. const marker = '========== AI 原始响应 ';
  4. const markerIdx = content.indexOf(marker);
  5. const headerEndIdx = content.indexOf(' ==========', markerIdx);
  6. const aiStart = content.indexOf('\n', headerEndIdx) + 1;
  7. const aiEnd = content.indexOf('\n\n', aiStart);
  8. const aiResponse = content.substring(aiStart, aiEnd);
  9. const pos = 523;
  10. // Check around position 500-550
  11. console.log('500-550 chars:');
  12. console.log(JSON.stringify(aiResponse.substring(500, 550)));
  13. console.log('\nActual bytes:');
  14. for (let i = 500; i < 550; i++) {
  15. const code = aiResponse.charCodeAt(i);
  16. process.stdout.write(i + ':' + code + '[' + aiResponse[i] + '] ');
  17. }
  18. console.log();
  19. // The context shows: ...呼吸"},{number":2,"title"
  20. // So at position 523 we have {number":2
  21. // This means "number" property name is missing opening quote!
  22. // Let's verify
  23. const snippet = aiResponse.substring(pos - 5, pos + 30);
  24. console.log('\nSnippet around error:', JSON.stringify(snippet));
  25. // The exact characters at positions 523-530
  26. console.log('\nChars 523-532:');
  27. for (let i = 523; i < 532; i++) {
  28. const code = aiResponse.charCodeAt(i);
  29. console.log(' pos', i, '=', code, JSON.stringify(aiResponse[i]));
  30. }
  31. // Check if maybe there's a stray quote or something
  32. // Look at what's between last " and the { at pos 523
  33. let lastFewChars = '';
  34. for (let i = 518; i < 523; i++) {
  35. lastFewChars += JSON.stringify(aiResponse[i]) + ' ';
  36. }
  37. console.log('\n518-522 chars:', lastFewChars);