근본원인: code 요소의 textContent '❯ project > command'가 PowerShell 키워드 (return, function, const)를 포함할 수 있어 JUNK_CODE_RE에 잘못 걸림. v32: ❯ 마커로 시작하는 code 텍스트는 JUNK/PROMPT 전에 명령어 직접 추출. 14/14 E2E 테스트 통과.
43 lines
1.5 KiB
JavaScript
43 lines
1.5 KiB
JavaScript
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');
|
|
}
|
|
}
|