/** * html-patcher 수정 검증 스크립트 * 실제 workbench.html + 실제 observer-script 출력물로 패치 시뮬레이션 */ const fs = require('fs'); const path = require('path'); // 1. 실제 깨끗한 workbench.html 읽기 const htmlPath = path.join( process.env.LOCALAPPDATA, 'Programs', 'Antigravity', 'resources', 'app', 'out', 'vs', 'code', 'electron-browser', 'workbench', 'workbench.html' ); let html = fs.readFileSync(htmlPath, 'utf8'); console.log(`[1] Clean HTML: ${html.length} chars, ${html.split('\n').length} lines`); console.log(` Has AG SDK: ${html.includes('AG SDK')}`); // 2. 실제 observer-script.ts의 출력 시뮬레이션 (generateApprovalObserverScript) const observerModule = require('./extension/out/observer-script'); const observerJS = observerModule.generateApprovalObserverScript(34332); console.log(`[2] Observer JS: ${observerJS.length} chars`); console.log(` Contains $': ${observerJS.includes("$'")}`); console.log(` Contains ')$': ${observerJS.includes("')$")}`); // 3. 패치 시뮬레이션 — 수정 전 (BUG) const inlineBlock_buggy = `\n\n`; let html_buggy = html.replace('', `\n${inlineBlock_buggy}\n`); // 4. 패치 시뮬레이션 — 수정 후 (FIX) const inlineBlock = `\n\n`; const safeInlineBlock = inlineBlock.replace(/\$/g, '$$$$'); let html_fixed = html.replace('', `\n${safeInlineBlock}\n`); console.log(`\n[3] BUGGY result: ${html_buggy.length} chars`); console.log(`[4] FIXED result: ${html_fixed.length} chars`); // 5. JS 코드 추출 및 SyntaxError 검증 function extractAndCheckJS(patchedHtml, label) { const match = patchedHtml.match(/