const {generateApprovalObserverScript} = require('../out/observer-script'); let s = generateApprovalObserverScript(18080); // Find the regex used in v30 candidate matching let idx = s.indexOf('candT.match('); if (idx < 0) idx = s.indexOf('sibT.match('); let reStr = s.substring(idx, s.indexOf(');', idx) + 1); console.log('Match code:', reStr.substring(0, 60)); // Extract just the regex part let reMatch = reStr.match(/\/(.*?)\//); let reSource = reMatch ? reMatch[0] : 'NOT FOUND'; console.log('Regex source:', reSource); // Build and test the actual regex let re = new RegExp(reMatch[1]); console.log('Regex object:', re); // Test with the EXACT patterns from logs let tests = [ ['Normal', '\u276f gravity_control > Start-Sleep 12 content_copy'], ['Git cmd', '\u276f gravity_control > git add -A; git commit -m "test"'], ['Short', '> content_copy'], ['Prompt only', '\u276f gravity_control > '], ['Dir cmd', '\u276f gravity_control > dir content_copy'], ]; console.log('\n=== REGEX TESTS ==='); let stripRe = /\s*(content_copy|content_paste|play_arrow|check_circle|keyboard_arrow[_a-z]*)\s*$/; for (let [name, text] of tests) { let m = re.exec(text); if (m) { let raw = m[1].trim(); let cleaned = raw.replace(stripRe, '').trim(); console.log(name + ':'); console.log(' raw match[1]: "' + raw + '"'); console.log(' after strip: "' + cleaned + '"'); console.log(' length ok: ' + (cleaned.length >= 3)); } else { console.log(name + ': NO MATCH'); } }